#1  
Old 17th September 2007, 10:26 PM
Dennis Landi
 
Posts: n/a
Default Best way of getting Empty Result Set

There were discussions on this over a year ago, I recall. But I don't
recall a consensus emerging.

What is the most efficient way of running a query to produce an empty
resultset?

Select * from MyTable
Where
....???

-d


  #2  
Old 17th September 2007, 10:50 PM
Chris
 
Posts: n/a
Default Re: Best way of getting Empty Result Set

True = false?
1=0?


  #3  
Old 17th September 2007, 10:55 PM
Dennis Landi
 
Posts: n/a
Default Re: Best way of getting Empty Result Set


"Chris" <nospam@nospam.com> wrote in message
news:46ee69de$1@nexus-vkpb9bih5.Nexus.local...
> True = false?
> 1=0?


Yep, I wonder if there is something even more efficient than that.

On a table with about 30 columns and 1000 records this takes 328 msecs.

It'll do, but...

-d


  #4  
Old 17th September 2007, 11:40 PM
Brian Evans [NDX]
 
Posts: n/a
Default Re: Best way of getting Empty Result Set

Dennis Landi wrote:
> "Chris" <nospam@nospam.com> wrote in message
> news:46ee69de$1@nexus-vkpb9bih5.Nexus.local...
>> True = false? 1=0?

>
> Yep, I wonder if there is something even more efficient than that.
>
> On a table with about 30 columns and 1000 records this takes 328
> msecs.
>
> It'll do, but...
>
> -d


Turn off request live since it causes it to evaluate the condition
for each record. Using TOP 0 will also prevent the query from
being live.

#L-
SELECT * FROM SOMETABLE WHERE 0=1;

or

SELECT TOP 0 * FROM SOMETABLE;

--
Brian Evans [NDX]
Ottawa, ON, CANADA
GMT-5
  #5  
Old 18th September 2007, 12:10 AM
Brian Evans [NDX]
 
Posts: n/a
Default Re: Best way of getting Empty Result Set

Brian Evans [NDX] wrote:
> Dennis Landi wrote:
>> "Chris" <nospam@nospam.com> wrote in message
>> news:46ee69de$1@nexus-vkpb9bih5.Nexus.local...
>>> True = false? 1=0?

>>
>> Yep, I wonder if there is something even more efficient than that.
>>
>> On a table with about 30 columns and 1000 records this takes 328
>> msecs.
>>
>> It'll do, but...
>>
>> -d

>
> Turn off request live since it causes it to evaluate the condition
> for each record. Using TOP 0 will also prevent the query from being
> live.
>
> #L- SELECT * FROM SOMETABLE WHERE 0=1;
>
> or
>
> SELECT TOP 0 * FROM SOMETABLE;
>


Opps, #L is for log. The request live query is an option
not a statement switch.

--
Brian Evans [NDX]
Ottawa, ON, CANADA
GMT-5
  #6  
Old 18th September 2007, 02:35 AM
Dennis Landi
 
Posts: n/a
Default Re: Best way of getting Empty Result Set


"Brian Evans [NDX]" <bevanson@rogers.com> wrote in message
news:46ee7ca8@nexus-vkpb9bih5.Nexus.local...

>> Turn off request live since it causes it to evaluate the condition for
>> each record. Using TOP 0 will also prevent the query from being
>> live.
>>
>> #L- SELECT * FROM SOMETABLE WHERE 0=1;
>>
>> or
>>
>> SELECT TOP 0 * FROM SOMETABLE;
>>

>
> Opps, #L is for log. The request live query is an option
> not a statement switch.


Thanks Brian.


  #7  
Old 18th September 2007, 05:45 AM
Chris
 
Posts: n/a
Default Re: Best way of getting Empty Result Set


"Dennis Landi" <nada@nada.com> wrote in message
news:46ee6b09$1@nexus-vkpb9bih5.Nexus.local...
>
> "Chris" <nospam@nospam.com> wrote in message
> news:46ee69de$1@nexus-vkpb9bih5.Nexus.local...
>> True = false?
>> 1=0?

>
> Yep, I wonder if there is something even more efficient than that.
>
> On a table with about 30 columns and 1000 records this takes 328 msecs.
>
> It'll do, but...
>
> -d
>


Seems odd, I've just tested against my address server table with 1.7m rows,
30 (ish) columns over my wireless network and it completes is 78ms. I guess
the 'request live' really does slow it down....yep, just tried and it takes
forever.


  #8  
Old 18th September 2007, 07:38 AM
Hannes Danzl[NDD]
 
Posts: n/a
Default Re: Best way of getting Empty Result Set

> Seems odd, I've just tested against my address server table with 1.7m rows,
> 30 (ish) columns over my wireless network and it completes is 78ms. I guess
> the 'request live' really does slow it down....yep, just tried and it takes
> forever.


Request live is essentially working like a server side sql filter.

--

Hannes Danzl [NexusDB Developer]
Newsgroup archive at http://www.tamaracka.com/search.htm
  #9  
Old 18th September 2007, 06:39 PM
Hans Hasenack
 
Posts: n/a
Default Re: Best way of getting Empty Result Set

Chris wrote:

> True = false?
> 1=0?


Would
WHERE True=False

actually be faster than
WHERE False

? I use the latter all the time. I even created a routine to change any
SQL statement
SELECT
....
WHERE .....

into
SELECT
....
WHERE FALSE AND ....

(I needed this just to get the output column names & types, and NO DATA)


--
Thanks,
Hans Hasenack (Netherlands)
  #10  
Old 17th September 2007, 10:53 PM
Dennis Landi
 
Posts: n/a
Default Re: Best way of getting Empty Result Set


"Dennis Landi" <nada@nada.com> wrote in message
news:46ee645c$1@nexus-vkpb9bih5.Nexus.local...
> There were discussions on this over a year ago, I recall. But I don't
> recall a consensus emerging.
>
> What is the most efficient way of running a query to produce an empty
> resultset?
>
> Select * from MyTable
> Where
> ...???
>


Anyone found faster than:

SELECT * FROM "MyTable" where 1 = -1

???

-d




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Column default option EMPTY Ole Willy Tuv nexusdb.public.support.sql 72 14th December 2006 09:25 PM
Returning an empty dataset Hans Hasenack nexusdb.public.support.sql 7 12th September 2006 05:26 PM
On the "empty identifier" front ... Martijn Tonies nexusdb.public.support.sql 3 7th September 2006 07:54 PM
Deliberately return an EMPTY ResultSet from a Query Dennis Landi nexusdb.public.support.sql 6 31st January 2006 07:19 AM
Result Fields are empty Bernhard Roos nexusdb.public.support.sql 6 3rd December 2005 04:31 AM


All times are GMT +11. The time now is 07:45 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.