Welcome to WebmasterWorld Guest from 50.16.126.107

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

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

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

Preferred Member

10+ Year Member

joined:Nov 19, 2002
posts:372
votes: 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?

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

Administrator

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 24, 2001
posts:15756
votes: 0


not sure but I'll bump it
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members