Created
September 3, 2012 06:56
-
-
Save lulalala/3607450 to your computer and use it in GitHub Desktop.
Mysql nested query slower than two distinct query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT `topics`.* FROM `topics` WHERE `topics`.`id` IN ( | |
SELECT DISTINCT `topic_comments`.`topic_id` FROM `topic_comments` WHERE (created_at > '2011-11-08 04:56:58') ORDER BY `topic_comments`.`created_at` DESC) | |
LIMIT 10 OFFSET 0; | |
SELECT DISTINCT `topic_comments`.`topic_id` FROM `topic_comments` WHERE (created_at > '2011-11-08 04:56:58') ORDER BY `topic_comments`.`created_at` DESC; | |
select topics.* from topics where topics.id in (45756,45334,44759,44799,44769,44697,43755,43445,43591,43754,42620,42643,42683,41333,42277,41678,41868,41610,41530,525,41336,41066,41067,41068,40596,40800,40575,40264,40292,40038,39744,39348,40082,39859,39702,40039,39532,38440,38658,8346,38218,37760,33297,37123,37353,37002,37089,36948,36870,36617,36727,16621,25468,25465,16972,8741,9604,17498,14175,14898,26513,26143,26058,10957,8799,35054,36728,36430,36393,36395,35816,7642,36278,36279,36097,24377,33299,35087,35053,32413,34660,34489,34510,33823,34077,33873,33557,32656,32600,33123,30970,32880,32924,116,29133,32274,32409,32104,32148,30946,31798,30962,31158,30969,30676,30677,30811,30538,30409,30408,30122,30189,18523,29667,29711,29714,29654,29666,29053,27083,28637,24776,28351,27796,27801,27559,27438,27393,26985,27267,26320,26939,25940,26465,25978,25620,1,24602,11490,25041,23421,24018,24704) LIMIT 10 OFFSET 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment