MySQL Forums
Forum List  »  Optimizer & Parser

Re: Subquery with range uses filesort
Posted by: Rick James
Date: December 18, 2013 05:49PM

> it is a shared server, so no guarantee my data would be cached

Define "shared".
* One instance of mysqld; each user has one database in it.
* Separate instances of mysqld for each user.

In the former case, I can see their reluctance to change anything. In the latter case, they should not be reluctant, other than to avoid overloading the RAM that is allotted to you.

> innodb_buffer_pool_size 8388608

8M is terribly small for InnoDB. So, don't switch to InnoDB unless you can get them to raise that value.

> so no guarantee my data would be cached

* Single instance -- other users could bump your blocks out of cache
* Multiple instances -- caching depends mostly on things that you control.

> doing a sort to find the most recent history record in the subquery rather than using the index.

Well... Data blocks and Index blocks are each cached. The difference in speed (between first and subsequent runs) is almost entirely due to caching. That is, if it used an index one time, it will use the index the other time. The first run is mostly I/O bound; subsequent runs are mostly CPU bound.

> join History on HistoryPlayer = PlayerID
> and ( HistoryDate, HistoryDirector ) = ( select ...

Please also try

join History h on HistoryPlayer = PlayerID
JOIN ( select ... ) x
ON h.History = x.HistoryDate AND h.HistoryDirector = x.HistoryDirector

(I may not have gotten the "h." correct.) The reason for asking for this that "WHERE (a,b) = (c,d)" is not always well optimized.

Options: ReplyQuote


Subject
Views
Written By
Posted
4332
November 16, 2013 02:42PM
1515
November 17, 2013 07:42PM
1525
November 17, 2013 08:01PM
1536
November 18, 2013 04:33PM
2065
November 18, 2013 07:54PM
1747
November 19, 2013 04:10PM
1639
November 19, 2013 08:36PM
1702
November 21, 2013 02:55PM
1908
December 05, 2013 03:46PM
1548
December 07, 2013 02:10PM
1514
December 09, 2013 06:08PM
1610
December 14, 2013 09:51PM
1477
December 14, 2013 10:17PM
1558
December 15, 2013 11:29PM
1632
December 17, 2013 06:58PM
Re: Subquery with range uses filesort
1557
December 18, 2013 05:49PM
1596
December 18, 2013 08:28PM
1627
December 19, 2013 10:13PM
1594
December 19, 2013 10:28PM
1450
December 20, 2013 07:06PM
1535
December 21, 2013 07:36AM
1583
December 22, 2013 10:01AM
1642
December 22, 2013 10:45AM
1544
December 25, 2013 09:30PM


Sorry, you can't reply to this topic. It has been closed.
This forum is currently read only. You can not log in or make any changes. This is a temporary situation.

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.