Subject Re: Using view in IBO
Author Svein Erling
> I could like to know if which is a better solution. Will there be
> a big difference in performance if I use view in Tib_query instead
> of a normal sql select.
>
> My sql is this:
>
> select * from "invoice"
> where "Type" in (select ID from "expensetype")
>
> If the view could be a better solution ... the view could derived
> from the sql above. As of now I do things without using view, as
> long as the sql is simple. What is the sql is compose of a lot of
> left joins what is the better solution then.

If this particular query causes you problems, then you may change to

select * from "invoice"
where exists(
select * from "expencetype"
where "invoice"."Type" = "expensetype".ID)

I think Firebird 1.5 is better than previous versions when doing IN
<subselect>, but EXISTS is definitely a better choice for earlier
versions.

Set