2

Which fields should be indexed to speed up the following query?

SELECT *
FROM sms_report
WHERE R_uid = '159'
AND R_show = '1'
ORDER BY R_timestamp DESC , R_numbers
1
  • now its using filesort, i need to optimize that. Commented Dec 18, 2010 at 13:42

1 Answer 1

3

Basing on this information, a composite index on (R_uid, R_show) should be good.

http://dev.mysql.com/doc/refman/5.5/en/multiple-column-indexes.html

To be able to tell anything more, you'd need to show us results of EXPLAIN

http://dev.mysql.com/doc/refman/5.5/en/explain.html

and tell which storage engine is being used.

Sign up to request clarification or add additional context in comments.

1 Comment

id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE sms_report ref R_uid,R_show R_uid 4 const 756276 Using where; Using filesort

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.