MySQL Forums
Forum List  »  Optimizer & Parser

Re: Subquery with range uses filesort
Posted by: David Marcus
Date: December 18, 2013 08:28PM

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

I believe there is one instance of mysqld, but I'm not sure how to
confirm that. Each user can have one or more databases.

> I can see their reluctance to change anything.

I don't know how reluctant they would be; I haven't asked them. They
might have another server tuned for InnoDB.

> > 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.

My statement about "doing a sort" was based on the output of the
"explain" statements.

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

select
PlayerID, PlayerName, PlayerPrimaryClub, PlayerCountry,
H.HistoryEvent, H.HistoryDate, H.HistoryFinalMean, H.HistoryFinalStDev
from Player
join History as H on HistoryPlayer = PlayerID
join
( select HistoryDate, HistoryDirector
from History
where HistoryPlayer = PlayerID and HistoryDate <= '2012-06-30'
order by HistoryDate desc, HistoryDirector desc limit 0,1 ) as S
on H.HistoryDate = S.HistoryDate and H.HistoryDirector = S.HistoryDirector
where PlayerID in (...)

Error Code: 1054. Unknown column 'PlayerID' in 'where clause'

Options: ReplyQuote


Subject
Views
Written By
Posted
4014
November 16, 2013 02:42PM
1425
November 17, 2013 07:42PM
1435
November 17, 2013 08:01PM
1436
November 18, 2013 04:33PM
1974
November 18, 2013 07:54PM
1663
November 19, 2013 04:10PM
1517
November 19, 2013 08:36PM
1598
November 21, 2013 02:55PM
1803
December 05, 2013 03:46PM
1453
December 07, 2013 02:10PM
1414
December 09, 2013 06:08PM
1461
December 14, 2013 09:51PM
1383
December 14, 2013 10:17PM
1461
December 15, 2013 11:29PM
1507
December 17, 2013 06:58PM
1445
December 18, 2013 05:49PM
Re: Subquery with range uses filesort
1500
December 18, 2013 08:28PM
1535
December 19, 2013 10:13PM
1509
December 19, 2013 10:28PM
1360
December 20, 2013 07:06PM
1448
December 21, 2013 07:36AM
1495
December 22, 2013 10:01AM
1549
December 22, 2013 10:45AM
1408
December 25, 2013 09:30PM


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.