MySQL Forums
Forum List  »  Performance

Re: INNODB large database performance
Posted by: Rick James
Date: February 20, 2013 05:31PM

14M rows? 10% of the tables discussed on these forums are bigger than that. 300 million will be 'huge'.

> PRIMARY KEY (`EntryDate`,`ChannelID`),

Can two rows for the same Channel be inserted with the same DATETIME? (Having any kind of date in a PRIMARY or UNIQUE key is a red flag in my book.)

(You have...)
SELECT  dt.GroupID AS ChannelID, dt.GroupName AS Description,
        dt.GroupDescription AS DeviceDescription,
        GROUP_CONCAT(DATE_FORMAT(`dt`.`Date`, '%M %e, %Y %k:%i:00') ORDER BY  `dt`.`Date` SEPARATOR '|') AS `EntryDate`,
        GROUP_CONCAT(dt.Total ORDER BY  `dt`.`Date` SEPARATOR '|') AS `Data`,
        GROUP_CONCAT(dt.Rate  ORDER BY  `dt`.`Date` SEPARATOR '|') AS `RateData`,
        SUM(dt.Total) AS ChannelTotal, SUM(`dt`.`Total`) * 0.34 AS `ChannelTotalCO2`,
        SUM(`dt`.`TotalCost`) AS ChannelTotalCost
    FROM  
      ( SELECT  SUM(d.`DataVal`)/1 AS Total, g.GroupID,
                g.`GroupName`, g.`GroupDescription`,
                `d`.`EntryDate` AS `Date`,
                SUM(IFNULL(`sr`.Rate, 0) * (d.DataVal/1)) AS `Rate`,
                SUM(IFNULL(`sr`.Rate, 0) * (d.DataVal/1)) AS `TotalCost`
            FROM  master.`channelgroup` cg
            LEFT JOIN  eddie.`groups` g ON cg.`GroupID` = g.`GroupID`
            LEFT JOIN  `data` d ON cg.ChannelID = d.`ChannelID`
            LEFT OUTER JOIN  `master`.`siterates` `sr` ON `d`.`SiteRateID` = `sr`.`SiteRateID`
            WHERE  (FIND_IN_SET(g.`GroupID`,'157, 78,87,79,91,81'))
              AND  ((d.EntryDate BETWEEN '2013-01-01 00:00:00' AND  '2013-02-15 23:59:59'))
            GROUP BY  g.GroupID, DATE_FORMAT(`d`.`EntryDate`, '%M %e, %Y %k:%i:00')
      ) AS dt
    GROUP BY  dt.GroupID
    ORDER BY  SUM(dt.Total) DESC;

> WHERE (FIND_IN_SET(g.`GroupID`,'157, 78,87,79,91,81'))

The performance of this worries me. If `GroupID` is one of those number, then this is much better:
WHERE g.GroupID IN (157, 78,87,79,91,81)

Please provide the EXPLAIN for the query.

> all join tables are indexed appropriately.

The EXPLAIN will reveal that.

Options: ReplyQuote


Subject
Views
Written By
Posted
3556
February 16, 2013 03:11AM
Re: INNODB large database performance
1197
February 20, 2013 05:31PM
1047
February 21, 2013 02:51AM
1279
February 21, 2013 11:12PM
1330
February 22, 2013 03:38AM
1030
February 23, 2013 12:04AM
988
February 23, 2013 03:28PM
928
February 24, 2013 02:10PM
926
February 24, 2013 03:02PM
1055
February 25, 2013 10:39PM


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.