Subject | Re: [firebird-support] LEFT JOIN AND ORDER BY |
---|---|
Author | Dmitry Yemanov |
Post date | 2004-11-18T17:05:10Z |
"aleskahanek" <akahanek@...> wrote:
much unless you need only a few rows instead of all 300K.
PERSON.LNAME,
( SELECT COMPANY.COM_NAME FROM COMPANY WHERE COMPANY.COM_ID =
PERSON.COM_ID )
FROM
PERSON
???
Dmitry
>Because it's not smart enough. Although I doubt this index would help you
> This query takes about 20 seconds
>
> SELECT PERSON.LNAME, COMPANY.COM_NAME
> FROM PERSON
> LEFT JOIN COMPANY ON PERSON.COM_ID=COMPANY.COM_ID
> ORDER BY PERSON.LNAME
>
> PLAN SORT (JOIN (PERSON NATURAL,COMPANY INDEX (RDB$PRIMARY4)))
>
> while this returns almost immediately (without sorting)
>
> SELECT PERSON.LNAME
> FROM PERSON
> LEFT JOIN COMPANY ON PERSON.COM_ID=COMPANY.COM_ID
>
> Why Firebird does not use the LNAME index for table PERSON?
much unless you need only a few rows instead of all 300K.
> I need to use LEFT JOIN and also order the result set according toSELECT
> LNAME.
PERSON.LNAME,
( SELECT COMPANY.COM_NAME FROM COMPANY WHERE COMPANY.COM_ID =
PERSON.COM_ID )
FROM
PERSON
???
Dmitry