pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Paul Thomas <paul@tmsl.demon.co.uk>
To: David Shadovitz <david_shadovitz@xontech.com>
Cc: pgsql-sql @ postgresql . org <pgsql-sql@postgresql.org>
Subject: Re: Fetch a single record
Date: Wed, 10 Dec 2003 00:11:29 +0000
Message-ID: <20031210001129.A30762@bacon> (raw)
In-Reply-To: <8b37e2e5.0312051351.4045b4e@posting.google.com>
References: <8b37e2e5.0312051351.4045b4e@posting.google.com>


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   |
+------------------------------+---------------------------------------------+



view thread (4+ messages)  latest in thread

Message-ID: <20031210001129.A30762@bacon>
Permalink:  ../20031210001129.A30762@bacon/
Also on:    postgresql.org/message-id/20031210001129.A30762@bacon

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: paul@tmsl.demon.co.uk, david_shadovitz@xontech.com
  Subject: Re: Fetch a single record
  In-Reply-To: <20031210001129.A30762@bacon>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox