B
bau
Hi Everybody,
I am working on a rather large table (>1,000,000 rows) containing
houshold level panel data and one of the subqueries is really slow:,
<code>
Select a.CustomerID, a.Brand,
(Select d.PurchaseCounter
b.PurchaseCounter=((a.PurchaseCounter)-1)
) AS D1
(Select d.PurchaseCounter
b.PurchaseCounter=((a.PurchaseCounter)-2)
) AS D2
FROM Customertable AS a
</code>
What this is supposed to be doing is finding out if the customer chose
the same brand on the last purchase occasion. In the real table, this
is done for the last 30 purchases. Everything works fine except of the
performance. I indexed everything and set all the data types to their
minimum. This whole project will yield one static table - however, the
way it is now i figured it would take about 50 hours to get this
table.
Is there any other way to do this or do you have any hints on how to
improve perfomance? I thought maybe an iff-statement would be better
here, but I cant get to work.
Thanks for your time!
Ray
I am working on a rather large table (>1,000,000 rows) containing
houshold level panel data and one of the subqueries is really slow:,
<code>
Select a.CustomerID, a.Brand,
(Select d.PurchaseCounter
Where a.CustID=b.CustID AND a.Brand=b.Brand ANDFrom Customertable AS b
b.PurchaseCounter=((a.PurchaseCounter)-1)
) AS D1
(Select d.PurchaseCounter
Where a.CustID=b.CustID AND a.Brand=b.Brand ANDFrom Customertable AS b
b.PurchaseCounter=((a.PurchaseCounter)-2)
) AS D2
FROM Customertable AS a
</code>
What this is supposed to be doing is finding out if the customer chose
the same brand on the last purchase occasion. In the real table, this
is done for the last 30 purchases. Everything works fine except of the
performance. I indexed everything and set all the data types to their
minimum. This whole project will yield one static table - however, the
way it is now i figured it would take about 50 hours to get this
table.
Is there any other way to do this or do you have any hints on how to
improve perfomance? I thought maybe an iff-statement would be better
here, but I cant get to work.
Thanks for your time!
Ray