Subject | Re: SQL Query performance |
---|---|
Author | Ali Gökçen |
Post date | 2005-07-11T07:44:44Z |
Hi Robert,
could you try..
SELECT a,b,c
FROM Table1 t1
JOIN Table2 t2 ON (t2.pk = t1.FK and t2.CancelFlag <> 'T')
WHERE t1.PK = 4
Ali
--- In firebird-support@yahoogroups.com, Robert martin <rob@c...>
wrote:
could you try..
SELECT a,b,c
FROM Table1 t1
JOIN Table2 t2 ON (t2.pk = t1.FK and t2.CancelFlag <> 'T')
WHERE t1.PK = 4
>Hi All"JOIN Table2 t2 t2" ???
>
>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'
Ali
--- In firebird-support@yahoogroups.com, Robert martin <rob@c...>
wrote:
> Hi Helenfields and
>
> Thanks for your reed back.
>
> I realized the * was not so hot, the real query specifies all
> actually contains a couple of other tables. The query shown belowmore
> simply demonstrates the problem. Your suggestion re using the =is a
> good one however I had already tested it to no avail.Interestingly
> adding the sl.* actually makes the SQL about 100ms slower !correct
>
> My further testing of other where clauses that would return the
> 208 records indicates that all are equally slow. The second Iflip the
> SQL around it runs fast, but of course returns the wrong results!just * instead of sl.*).
>
> for example your query
>
> SELECT sl.* /* notice the identifier! */
> FROM SupplyLine sl
> JOIN SupplyOrder so ON so.SupOrdrRef = sl.SupOrdrRef
> WHERE so.EntityRef = 4
> AND sl.SupTranRef IS NULL
> AND sl.PackSlpRef IS NULL
> AND (sl.CancelFlag = 'F' or sl.CancelFlag is null)
>
> Returns 208 records and takes 1.568ms
>
> The same query with the F changed to T
>
> SELECT sl.* /* notice the identifier! */
> FROM SupplyLine sl
> JOIN SupplyOrder so ON so.SupOrdrRef = sl.SupOrdrRef
> WHERE so.EntityRef = 4
> AND sl.SupTranRef IS NULL
> AND sl.PackSlpRef IS NULL
> AND (sl.CancelFlag = 'T' or sl.CancelFlag is null)
>
> returns 334 records and takes 0.125s (note it takes 0.079s with
>
> This is all very strange :)
>
>
>
>
> >
> >