homepage Welcome to WebmasterWorld Guest from 54.226.43.155
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
[mysql] how do u optimize Select Newest N result from BIG range
Xuefer




msg:1312137
 1:05 pm on Jan 21, 2005 (gmt 0)

TABLE thread (
threadid INT,
forumid INT,
ctime INT, (creation time)
...
)
PRIMARY KEY threadid, auto_increment
INDEX(forumid,ctime)

query:
select .. from thread where forumid=1 and ctime>$one_month_ago order by ctime DESC
LIMIT 10

EXPLAIN gives "use index" and NO filesort, thus mysql will find by index as stop as soon as LIMIT exceed

but i now modify "forumid=1" to "forumid IN($idlist)", and EXPLAN gives "use index, filesort", which will get ALL match result from table into tmpfile, and sort as soon as LIMIT of rows is found.

btw: $idlist is not too much, but "thread"s in it is too many rows

any idea?

 

jatar_k




msg:1312138
 6:37 pm on Jan 22, 2005 (gmt 0)

not sure but I'll bump it

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved