Subject Re: [firebird-support] slow "where 1=0"
Author Adriano dos Santos Fernandes
danyschaer escreveu:
> Hi Forum;
>
> I use to run
>
> select * from TABLE where 1=0
>
> to fill an empty datataset with fields structure of any table. The
> thing is that Firebird needs a little while (sometimes a few seconds)
> to do it; but, he no time to make for example:
>
> select * from TABLE where FIELD='Z'
>
> when there is no row with that condition; end even if the table is a
> half million records.
>
> Why he need that time to do "where 1=0" ??. I found that because my
> application stops execution for a few seconds each time I do that.

Firebird didn't infer that 1 = 0 is false for all rows and scan the
entire table. You'd better write the query as:
select first 0 * from TABLE;


Adriano