MySQL Forums
Forum List  »  General

Re: Seemingly erratic behavior
Posted by: Peter Brawley
Date: April 16, 2015 09:57PM

On these fora, use BBCode code tags to preserve text formatting.

Five left joins and much IFing and ORing. It's going to be slow.

The behaviour you describe suggests you're running out of memory so it's having to swap, and it's thrashing. Run Explain Extended on it and multiply the row counts to see just how many table rows it has to read. Post the Explain result and the result of Show Create Table for each table.

Have you proved that you need all that IFing and ORing and JOINing just to get one set of counts?

Some simplifications would likely speed it up if the right covering indexes are in place, eg if you write ...

set @today = unix_timestamp(curdate(), ' 23:59:59') );

then ...

IF( FROM_UNIXTIME(p.start_date) > concat(CURDATE( ) , ' 23:59:59'),

...becomes...

IF( p.start_date > @today,

which the optimiser can work with.

Options: ReplyQuote


Subject
Written By
Posted
Re: Seemingly erratic behavior
April 16, 2015 09:57PM


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.