hi experts,
Is it possible that i could get the 3 queries made into one single query.Any help could make me understand and correct myelf in better queries. Each query is taking long time and sometimes the first query crashes , with
> show processlist
showing status as 'copying to tmp data'
Thanks for concern and consideration
Thanks.
Saff
CREATE TABLE `yk_contributor_aging` (
`contributor_id` int(10) NOT NULL default '0',
`descale` float default NULL,
`rating_credit` float NOT NULL default '0',
`comment_credit` float NOT NULL default '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
---------------------------------------------------------------------------------------------------------
Query below inserts the contributor id and descale columns ( takes too much time that hangs )
---------
insert into `yk_contributor_aging` ( contributor_id, descale) SELECT yk_contribution.contributor_id, SUM(log(7, 365)-log(7, DATEDIFF(now(), yk_contribution.contribution_date ))) as descale FROM yk_contribution,yk_rating, yk_entity_score WHERE yk_entity_score.entity_key = yk_contribution.key AND DATEDIFF(now(), yk_contribution.contribution_date ) <= 365 GROUP BY yk_contribution.contributor_id ORDER BY yk_contribution.contributor_id ;
----------------------------------------------------------------------------------------------------------
Query below selects comment credit and is written to sql file for inserts the comment_credit column in yk_contributor_aging table
select contribution_date, cor.contributor_id, ( log(10,SUM(((log(7, 365) - log(7,DATEDIFF(NOW(), contribution_date )))/(log(7,365))))) / 3) as credit from yk_contribution as cion,yk_contributor as cor WHERE cor.contributor_id=cion.contributor_id GROUP by cion.contributor_id ORDER BY cion.contributor_id;
-----------------------------------------------------------------------------------------------------------
Query below selects comment credit and is written to sql file for inserts the comment_credit column in yk_contributor_aging table
select rating.contributor_id, ( log(10,SUM(((log(7, 365) - log(7,DATEDIFF(NOW(), rating_date )))/(log(7,365))))) / 4) as credit from yk_rating as rating, yk_contributor as cor WHERE cor.contributor_id = rating.contributor_id GROUP BY contributor_id ORDER BY contributor_id;