MySQL Forums
Forum List  »  Data Warehouse

Re: Performance problem in InnoDB
Posted by: Rick James
Date: December 08, 2010 02:46AM

Instead of indexing just PIDType on subnetDim, suggest using this compound index:
INDEX(PIDType, subnet_key)
That should change the EXPLAIN to saying "using index", and be a little faster.

Similarly add
INDEX(customer_name, b2bunit_key)
to B2BUnitDimension.

The optimizer may pick one of those indexes sometimes, then pick the other one other times. Alas, it can't really use both.

The real problem is that the WHERE clause is split between two tables:
AND subnetDim.PIDType = 'LOCAL'
and b2bDim.customer_name = 'turktel'
so the optimizer has to carry lots of rows form one of the tables before throwing them away when it gets to the other one. This is sometimes a problem with a properly 'normalized' data warehouse design.

Well, maybe you could trick it into using both indexes...
SELECT ...
FROM FACT
JOIN ( select subnet_key from subnetDim where PIDType = 'LOCAL' ) ON ...
JOIN ( select b2bunit_key FROM b2bDim WHERE customer_name = 'turktel' ) ON ...

Or, it may require working harder:
SELECT ...
FROM FACT
JOIN ( SELECT id FROM FACT
JOIN ( select subnet_key from subnetDim where PIDType = 'LOCAL' ) ) ON ...
JOIN ( SELECT id FROM FACT
JOIN ( select b2bunit_key FROM b2bDim WHERE customer_name = 'turktel' ) ) ON ...

This is half-baked. Maybe later I will think this thru further.

Options: ReplyQuote


Subject
Views
Written By
Posted
5808
November 29, 2010 08:03AM
2634
December 02, 2010 12:44AM
Re: Performance problem in InnoDB
2483
December 08, 2010 02:46AM


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.