Subject Re: [firebird-support] SQL Query performance
Author Robert martin
Hi

Just to add to the previous email. I have noticed that if I change the

AND t2.CancelFlag <> 'T'

to

AND t2.CancelFlag <> 'F'

The performance is fast.


Changing to = 'F' is fast, changing to = 'T' is slow.

The number of records returned in the <> 'F' where clause is also
greater !

<> 'F' returns 330
<> 'T' returns 208

Now I am really confused. Is there some sort of optimisation for 'T'
character comparisons?


Rob Martin
Software Engineer

phone +64 03 377 0495
fax +64 03 377 0496
web www.chreos.com

Wild Software Ltd



Robert martin wrote:

>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
>
>
>