Subject Re: [firebird-support] Simple SELECT statement causes long running query
Author Trond
This is a Cartesian join, and it will not run forever, but it will
probably take a while :)
(The index will not help either, unless you got an additional descending
index on the ID field.)

You are reading approximately 625 000 000 records, and the result set
will consist of
approximately 25 K identically records (I think). What you miss is the
relationship between the tables. >... Where T1.Field=T2.Field
(or use the join statement >... From Table1 T1 Join Table2 T2
on(T1.field=T2.field)).

If there is no relationship, you can use a sub query :

Select MAX(T1.ID) , (Select MAX(T2.ID) from Table2 T2)
from Table1 T1

Trond

> Hi,
>
> running the following query against Firebird 1.50
> causes the server to compute for a very long (infinite?)
> time:
>
> SELECT MAX (T1.ID),
> MAX (T2.ID)
> FROM Table1 T1, Table2 T2
>
> The two ID Fields are PKs, both table contain approximately
> 25 K records.
>
> I have never used such a query before, so I am wondering
> if it is valid or invalid and what is causing Firebird to
> work so long.
>
>
> Thanks in advance,
>
>
> Christian
>
>
>
>
> Yahoo! Groups Links
>
>
>
>



--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/