MySQL Forums
Forum List  »  Performance

Re: INNODB large database performance
Posted by: Rick James
Date: February 24, 2013 02:10PM

> I have been investigating maybe using merge tables for each years worth of data as i would only ever query a months worth of data MAX so maybe this would improve performance???

Maybe. (And I would use PARTITION, not MERGE.) If the WHERE clause restricts the query based on the 'partition key' (which seems to be the case only for d.EntryDate), and you cannot make good use of indexes, then PARITION is likely to help.

> Also make it easier to archive a years worth of data too and to unarchive it if needed.

Once you PARTITION, and pruning is working, there is no good reason to deal with archiving.

(Now you have)
EXPLAIN 
SELECT  SQL_NO_CACHE 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
    JOIN  master.`groups` g ON cg.`GroupID` = g.`GroupID`
    JOIN  `data` d ON cg.ChannelID = d.`ChannelID`
    LEFT OUTER JOIN  `master`.`siterates` `sr` ON `d`.`SiteRateID` = `sr`.`SiteRateID`
    WHERE  (g.`GroupID` IN (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, LEFT(d.EntryDate, 16)

`d` needs INDEX(ChannelID, EntryDate)

If that index does not help enough, look into Summary Tables.

Options: ReplyQuote


Subject
Views
Written By
Posted
3550
February 16, 2013 03:11AM
1195
February 20, 2013 05:31PM
1044
February 21, 2013 02:51AM
1277
February 21, 2013 11:12PM
1327
February 22, 2013 03:38AM
1027
February 23, 2013 12:04AM
985
February 23, 2013 03:28PM
Re: INNODB large database performance
925
February 24, 2013 02:10PM
923
February 24, 2013 03:02PM
1053
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.