pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: david_shadovitz@xontech.com
To: pgsql-sql@postgresql.org
Subject: Fetch a single record
Date: 5 Dec 2003 13:51:20 -0800
Message-ID: <8b37e2e5.0312051351.4045b4e@posting.google.com> (raw)

I'm looking for the fastest way to fetch a single record from a table.
 I don't care what record it is.

Here are two techniques I've explored:

1. Use LIMIT
SELECT * FROM myTable LIMIT 1

2. Get a valid OID and then get the record.
SELECT MIN(oid) AS anOID FROM myTable
SELECT * FROM myTable WHERE oid = anOID

The 1st technique is slow.  (I think PostgreSQL fetches all records
and then returns just one.)  The 2nd is faster, but not fast enough.

Any other ideas?  Please reply to me personally (david@shadovitz.com)
as well as to the list.

Thanks.
-David



view thread (4+ messages)  latest in thread

Message-ID: <8b37e2e5.0312051351.4045b4e@posting.google.com>
Permalink:  ../8b37e2e5.0312051351.4045b4e@posting.google.com/
Also on:    postgresql.org/message-id/8b37e2e5.0312051351.4045b4e@posting.google.com

 · 

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: david_shadovitz@xontech.com
  Subject: Re: Fetch a single record
  In-Reply-To: <8b37e2e5.0312051351.4045b4e@posting.google.com>

* 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