indexing question
Posted
by
user522962
on Stack Overflow
See other posts from Stack Overflow
or by user522962
Published on 2010-12-25T15:04:03Z
Indexed on
2010/12/25
15:54 UTC
Read the original article
Hit count: 166
mysql
I have a table w/ 3 columns: name, phone, date. I have 3 indexes: 1 on phone, 1 on date and 1 on phone and date. I have the following statement:
SELECT * FROM ( SELECT * FROM people WHERE phone IS NOT NULL ORDER BY date DESC) as t GROUP BY phone
Basically, I want to get all unique phone numbers ordered by date. This table has about 2.5 million rows but takes forever to execute....are my indexes right?
UPDATE:
My EXPLAIN statement comes back with 2 rows: 1 for primary table and 1 for derived table.
It says I am using temporary and using filesort for my primary table.
For my derived table, it says my possible keys are (phone), and (phone, date) but it is using filesort.
© Stack Overflow or respective owner