Hello,
I have a very basic query.
Table VI has 500k records, primary key is VI.ID, and the field I'm filtering is VI.sku, which has an index.
If I do:
The query runs in less that a second and all is well.
However, my application is more complex and I want to allow the user to have one or two sku's, or maybe three. Even a hundred if he feels like it.
So I created a SKU_AUTH table that's being fed lines from the form the user sees. Its only field and primary key is SKU_AUTH.sku
Same situation, the user just wants "ABCD" so SKU_AUTH has 1 line ("ABCD")
I run the query:
That query takes a good five minutes to return the result.
I don't understand why. Are inner joins inherently terrible for this kind of work, should I work with an IN() parameter instead?
I have a very basic query.
Table VI has 500k records, primary key is VI.ID, and the field I'm filtering is VI.sku, which has an index.
If I do:
Code:
select count(vi.id), vi.sku
from vi
where vi.sku="ABCD"
group by vi.sku
The query runs in less that a second and all is well.
However, my application is more complex and I want to allow the user to have one or two sku's, or maybe three. Even a hundred if he feels like it.
So I created a SKU_AUTH table that's being fed lines from the form the user sees. Its only field and primary key is SKU_AUTH.sku
Same situation, the user just wants "ABCD" so SKU_AUTH has 1 line ("ABCD")
I run the query:
Code:
Select count(VI.ID), VI.sku
from VI inner join SKU_AUTH on VI.sku=SKU_AUTH.sku
group by VI.sku
That query takes a good five minutes to return the result.
I don't understand why. Are inner joins inherently terrible for this kind of work, should I work with an IN() parameter instead?
Last edited: