Subject | Re: [Firebird-Architect] Re: the insert into t select * from t infinite |
---|---|
Author | Dmitry Yemanov |
Post date | 2005-07-05T21:28:57Z |
"Alexandre Benson Smith" <iblist@...> wrote:
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.
No doubt, both parser and optimizer should be able to perform the required
transformations. But this is completely unrelated issue, sorry.
Dmitry
>They are different. IN _is_ a correlated subquery, because it's being
> 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 ?
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.
> The query could be rewriten as:Only if B_ID is a primary key. Otherwise, this is completely wrong.
> select
> A.*
> from
> A
> join B on (B.B_ID = A.B_ID)
> where
> B.B = 'X'
No doubt, both parser and optimizer should be able to perform the required
transformations. But this is completely unrelated issue, sorry.
Dmitry