Subject | SQL Query performance |
---|---|
Author | Robert martin |
Post date | 2005-07-11T02:14:03Z |
Hi All
I have a Query that is basically
SELECT a,b,c
FROM Table1 t1
JOIN Table2 t2 t2 ON t2.pk = t1.FK
WHERE t1.PK = 4
AND t2.CancelFlag <> 'T'
The final and clause (t2.CancelFlag <> 'T' ) is really slowing the query
down. It takes 1.3s with and is near instantaneous without. The
CancelFlag field is a Char(1) field that is NOT indexed (because it
would have low selectivity). Is there anything I can do to speed up
this query?
In the data I am testing the table sizes are...
t1 = 3100
t2 = 72000
--
Rob Martin
Software Engineer
phone +64 03 377 0495
fax +64 03 377 0496
web www.chreos.com
Wild Software Ltd
I have a Query that is basically
SELECT a,b,c
FROM Table1 t1
JOIN Table2 t2 t2 ON t2.pk = t1.FK
WHERE t1.PK = 4
AND t2.CancelFlag <> 'T'
The final and clause (t2.CancelFlag <> 'T' ) is really slowing the query
down. It takes 1.3s with and is near instantaneous without. The
CancelFlag field is a Char(1) field that is NOT indexed (because it
would have low selectivity). Is there anything I can do to speed up
this query?
In the data I am testing the table sizes are...
t1 = 3100
t2 = 72000
--
Rob Martin
Software Engineer
phone +64 03 377 0495
fax +64 03 377 0496
web www.chreos.com
Wild Software Ltd