MySQL Forums
Forum List  »  Partitioning

Re: slower queries after partitioning
Posted by: Rick James
Date: October 23, 2010 01:24AM

select  a.TickerID, b.Ticker, b.Name
    from  quotes_copy as a,
          tickers as b
    where  DBDate =
      ( SELECT  min(DBDate) from  quotes)
      and  a.TickerID = b.TickerID;
-->
select  a.TickerID, b.Ticker, b.Name
    from  quotes_copy as a,
          tickers as b
    where  a.TickerID = b.TickerID
    ORDER BY a.DBDate
    LIMIT 1; 
and have this
KEY `TickerID` (`TickerID`, DBDate)
instead of
KEY `TickerID` (`TickerID`)

Any query on DBDate has to hit all partitions.

"Why is the partitioned table so much slower?" The lure of PARTITION beguiling, but often deceptive. Only 3M rows, and no query that takes advantage of PARTITIONing --> no benefit. I'm surprised to see it running that much slower.

double(12,4) -- not optimal for money -- this rounds to 4 decimal places, then converts to binary, which introduces a small error. Consider DECIMAL(10,4).

A 3:5 split will make a mess of your fractions.

Volume for some indexes has exceeded 4G.

With only 704 tickers, `TickerID` int(11) unsigned is excessive. Consider SMALLINT UNSIGNED (max of 65,535).

`DBDate` int(11) unsigned -- You don't what to use the builtin DATE datatype?

This one is fast because it simply fetches the first row in the table:
select min(DBDate) from quotes; 31 ms
With PARTITIONing, it has to fetch 250 'first' rows, sort them, then deliver the first. (Or something like that)

Options: ReplyQuote


Subject
Views
Written By
Posted
7918
October 21, 2010 11:46AM
Re: slower queries after partitioning
3204
October 23, 2010 01:24AM
2518
October 23, 2010 08:44AM
2783
October 23, 2010 09:43AM
2171
October 23, 2010 10:48AM
2128
October 23, 2010 10:57AM
2218
October 23, 2010 06:09PM
1958
October 24, 2010 02:30AM
1995
October 25, 2010 07:39AM
2019
October 25, 2010 08:04AM


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.