Subject | Re: [Firebird-Architect] Re: the insert into t select * from t infinite |
---|---|
Author | Alexandre Benson Smith |
Post date | 2005-07-05T21:57:19Z |
Dmitry Yemanov wrote:
I get in this discussion because I thoght that the Arno's proposition to
execute first the sub-select to make a list of values should apply to
this case too...
thanks for your time !
--
Alexandre Benson Smith
Development
THOR Software e Comercial Ltda.
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br
>"Alexandre Benson Smith" <iblist@...> wrote:I thought was converted _exactly_ to EXISTS.
>
>
>>One thing that most newcomers to FB strikes is
>>
>>select
>> *
>>from
>> A
>>where
>> AI.B_ID in (select B.B_ID from B where B.B = 'X')
>>
>>This query are treated as correlated, but in fact aren't there is some
>>possibility to solve the both problems (infinite loop and this) at once ?
>>
>>
>
>They are different. IN _is_ a correlated subquery, because it's being
>converted to this:
>
> exists (select 1 from B where B.B = 'X' and AI.B_ID = B.B_ID)
>
>(not exactly EXISTS, but something similar)
>
>This allows to use an index for the subquery link.
>
>
>Yep.. but it's the majority of the cases as I see the use of in (sub-select)
>
>>The query could be rewriten as:
>>select
>> A.*
>>from
>> A
>> join B on (B.B_ID = A.B_ID)
>>where
>> B.B = 'X'
>>
>>
>
>Only if B_ID is a primary key. Otherwise, this is completely wrong.
>
>
>
>No doubt, both parser and optimizer should be able to perform the requiredOk. understood.
>transformations. But this is completely unrelated issue, sorry.
>
>
I get in this discussion because I thoght that the Arno's proposition to
execute first the sub-select to make a list of values should apply to
this case too...
thanks for your time !
>see you !
>Dmitry
>
>
>
--
Alexandre Benson Smith
Development
THOR Software e Comercial Ltda.
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br