Subject | Re: [firebird-support] Another Unoptimized question |
---|---|
Author | |
Post date | 2013-04-16T14:12:14Z |
Subselects never get optimized in the way you posted.
Bad but truth.
Em 16/04/2013 11:09, "skander_sp" <skander_sp@...> escreveu:
Bad but truth.
Em 16/04/2013 11:09, "skander_sp" <skander_sp@...> escreveu:
> **[Non-text portions of this message have been removed]
>
>
>
> May be obvious, but til now, i don't see how much unoptimized works the
> "field in subselect" syntax.
>
> I'm using it in some procedure, just right til now, after check they work
> in the worse unoptimized mode...
>
> example:
>
> select * from Table1 T1
> where T1.id in (select T2.id
> from Table2 T2
> where T2.Customer=:customer)
>
> of course T2.id is a Primary key and T1.id is a Foreing key
>
> I think they resolve getting the value(s) in the subselect, and then
> applying to the main where, but the performace analisys show he run all the
> T1 table from begin to end and then check with the subselect
>
> of course I can solve (in procedure) with a FOR subselect to get every
> value and check after.... not the nicest way, and pretty ugly and less
> "human readable", but by far much more quick and optimized.
>
> for select T2.id
> from Table2 T2
> where T2.Customer=:customer
> into :id do
> select * from Table1 T1
> where T1.id=:id
>
> There is some way to get a good result using "field in subselect"? some
> trick to get an optimized result using this syntax?
>
>
>