MySQL Forums
Forum List  »  General

Re: Sending data in processlist
Posted by: Rick James
Date: December 20, 2014 12:03AM

Subqueries often are slow.
You have:
select  shutDownFlag, time_of_ping, observedstate, simulatedstate
    from  test100
    where  time_of_ping = 
      ( SELECT  max(time_of_ping)
            from  test100
            where  !(observedstate=4
                      and  powercost=0)
      )
See if this gives you what you want, but much faster:
SELECT  b.shutDownFlag, b.time_of_ping, b.observedstate, b.simulatedstate
    FROM  
      ( SELECT  max(time_of_ping) AS last_ping
            from  test100
            where  !(observedstate=4
                      and  powercost=0) 
      ) AS a
    JOIN  test100 AS b ON b.time_of_ping = a.last_ping;
Also, be sure to have time_of_ping indexed.

Options: ReplyQuote


Subject
Written By
Posted
December 19, 2014 07:55AM
Re: Sending data in processlist
December 20, 2014 12:03AM
December 20, 2014 05:33AM
December 20, 2014 10:18AM
December 26, 2014 02:23AM
December 26, 2014 11:56AM
December 29, 2014 02:59AM
December 29, 2014 01:16PM
December 30, 2014 07:02AM
December 30, 2014 02:55PM
January 01, 2015 01:55AM
January 01, 2015 08: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.