Re: Fetch a single record - Mailing list pgsql-sql

From Paul Thomas
Subject Re: Fetch a single record
Date
Msg-id 20031210001129.A30762@bacon
Whole thread Raw
In response to Fetch a single record  (david_shadovitz@xontech.com (David Shadovitz))
List pgsql-sql
On 05/12/2003 21:51 David Shadovitz wrote:
> I'm looking for the fastest way to fetch a single record from a table.
>  I don't care what record it is.
> [snip]

Have you also tried  SELECT * from mytable limit 1

If you genuinely don't care what the record is (I assume you're justing 
testing that table is not empty?) then this might be the way to go. My 
rather limited knowledge of PG internals leads me to believe that this 
will generally cause just one page being read from disk (I'm assuming the 
99% case of no mega-sized text/bytea/whatever columns here). I'd be 
interested to know just how far off the mark by understanding is...

-- 
Paul Thomas
+------------------------------+---------------------------------------------+
| Thomas Micro Systems Limited | Software Solutions for the Smaller 
Business |
| Computer Consultants         | 
http://www.thomas-micro-systems-ltd.co.uk   |
+------------------------------+---------------------------------------------+


pgsql-sql by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: Values like ''
Next
From: greg@turnstep.com
Date:
Subject: Re: Fetch a single record