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.
Subject
Views
Written By
Posted
3573
October 13, 2010 08:45PM
Re: I need Optimizaton of a Query - DISTINCT
1497
October 16, 2010 04:22PM
1655
October 16, 2010 06:29PM
1485
October 17, 2010 11:15AM
14289
October 17, 2010 08:36PM
1445
October 17, 2010 08:50PM
1576
October 17, 2010 10:51PM
1451
October 18, 2010 12:35AM
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.