Subject | Re: slow "where 1=0" |
---|---|
Author | Adam |
Post date | 2008-06-21T01:54:04Z |
--- In firebird-support@yahoogroups.com, "danyschaer" <danyschaer@...>
wrote:
optimisation. It will perform a natural read on TABLE and check for
each record whether 1=0. We used to run into this problem a bit but I
haven't for quite some time.
One option is to check for an impossible primary key. Ours are all
generator derived (so they start at 1), so we could use "where ID=0"
to ensure no rows are returned. If you can't guarantee such records
don't exist, then perhaps an impossible combination such as "where
ID=0 and ID=1" would do the trick.
Otherwise, you can try "FIRST 0" or "ROWS 0 TO 0" (I haven't tested).
Adam
wrote:
>Whether you like it or not, Firebird has not implemented this
> Hi Forum;
>
> I use to run
>
> select * from TABLE where 1=0
optimisation. It will perform a natural read on TABLE and check for
each record whether 1=0. We used to run into this problem a bit but I
haven't for quite some time.
One option is to check for an impossible primary key. Ours are all
generator derived (so they start at 1), so we could use "where ID=0"
to ensure no rows are returned. If you can't guarantee such records
don't exist, then perhaps an impossible combination such as "where
ID=0 and ID=1" would do the trick.
Otherwise, you can try "FIRST 0" or "ROWS 0 TO 0" (I haven't tested).
Adam