If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > How to optimize ORDER BY query with COUNT() and GROUP BY.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-22-06, 05:59
Nilnandan joshi Nilnandan joshi is offline
Registered User
 
Join Date: Dec 2006
Posts: 2
How to optimize ORDER BY query with COUNT() and GROUP BY.

Hi,

I have one query like

Select field_1, count(field_2) as cnt from Table_1
where field_3 like '%abc%' and field_4 like '%def%'
Group By field1
Order By cnt DESC
Limit 0,10

How can i optimize this query b'coz without Order By this takes 0.417 second but when we enter ORDER BY then it takes 4 to 5 seconds.we can not make index on count field...so now wht should i do to make this query fast???

Pls give me answer ASAP

Thanks in advance
Nilnandan Joshi
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On