MySQL Forums
Forum List  »  Performance

Re: speed of query/can index help?
Posted by: Rick James
Date: June 30, 2009 10:36PM

If you are going to do
where day=26
you should have
INDEX(day)

Without the WHERE, you are stuck with scanning your big table, and fetching info from the smaller one. Currently it is fetching 7M (or whatever) rows form the big table and another 7M probes into the smaller. We can shrink the second number to 2K, thereby doubling the speed (perhaps):
Before:
select  count(*), D.sev, D.msgNum, D.SDS_loghost, 
        A.aCtion
    from  syslogD D
    left join  syslogDAlert_data A  on A.msgID = D.msgNum
    group by  D.msgNum;

After:
select X.ct, X.sev, X.msgNum, X.SDS_loghost,
       A.aCtion
    from
    ( select  count(*) as ct, D.sev, D.msgNum, D.SDS_loghost
        from  syslogD D
        group by  D.msgNum
    ) X
    left join  syslogDAlert_data A  on A.msgID = X.msgNum

I still think the GROUP BY is "wrong". Which "sev" will you get?

The next performance boost will be very big -- but complicated. You would need to build daily "summary" info, and put it into a different table.

Options: ReplyQuote


Subject
Views
Written By
Posted
4060
June 26, 2009 06:15PM
1890
June 26, 2009 08:56PM
1968
June 27, 2009 03:04AM
1823
June 27, 2009 10:39AM
1782
June 30, 2009 12:26AM
Re: speed of query/can index help?
1926
June 30, 2009 10:36PM
1734
July 01, 2009 08:22PM


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.