List:General Discussion« Previous MessageNext Message »
From:Geoffrey Sneddon Date:August 12 2006 8:40pm
Subject:Do I really need a subquery?
View as plain text  
Hi,

I've ended up with the following SQL:

SELECT `title`, `url`, COUNT(1) AS  `count`, CEIL(COUNT(1) / (SELECT  
COUNT(1) AS `count` FROM `bi_bookmarks` WHERE `date` > NOW() -  
INTERVAL 86400 SECOND GROUP BY `url` ORDER BY `count` DESC LIMIT 0,  
1) * 8) AS `weight` FROM `bi_bookmarks` WHERE `date` > NOW() -  
INTERVAL 86400 SECOND GROUP BY `url` ORDER BY  `count` DESC LIMIT 0, 10;

Do I really need that subquery? It seems rather pointless having  
similar queries like that. Any other optimisations tips are of course  
welcome (just to note, there are reasons for having the interval in  
seconds).

- Geoffrey Sneddon



Thread
Do I really need a subquery?Geoffrey Sneddon12 Aug
  • Re: Do I really need a subquery?Peter Brawley13 Aug