MySQL Forums
Forum List  »  MyISAM

Re: I need Optimizaton of a Query - DISTINCT
Posted by: Rick James
Date: October 16, 2010 04:22PM

To assist in analyzing slow SELECTs, please provide
* SHOW CREATE TABLE tbl\G -- engine, indexes
* SHOW TABLE STATUS LIKE 'tbl'\G -- sizes
* EXPLAIN SELECT ...\G -- clues of inefficiencies
* SHOW VARIABLES LIKE '%buffer%'; -- cache size
and surround them with [ code ] and [ / code ]

DISTINCT makes sure you don't have two identical output rows. Is that even possible in the data? Is u.id the PRIMARY KEY for u? If there are never dups, why have DISTINCT?

DISTINCT needs to read all the rows and de-dup them. This may involve a sort, or it may be done by some other means.

Do you have
INDEX(created)
It might be the best bet for optimizing.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: I need Optimizaton of a Query - DISTINCT
1497
October 16, 2010 04:22PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.