Subject Re: [firebird-support] Select * from where 0=1
Author Martijn Tonies
Hi,

> I need to retrieve an empty resultset with all fields of a given table. I
> tried the two following queries :
>
> #1 : Select * from <table> where 0=1
> #2 : Select first 0 * from <TableName>
>
> First one seems to care about the amount of data in the queried table,
while
> the second one does not.
>
> Against an empty table, both queries perform the same.
> On a 15 million table, #1 takes 1.8s while #2 takes 20ms.
>
> I need to come up with a statement that's as fast a #2 but also works on
> most IB/FB engines.
> How should this statement look like ?

select * from table where pkcolumn = nonexistingvalue.

With regards,

Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server.
Upscene Productions
http://www.upscene.com