Fetch a single record

From: david_shadovitz(at)xontech(dot)com (David Shadovitz)
To: pgsql-sql(at)postgresql(dot)org
Subject: Fetch a single record
Date: 2003-12-05 21:51:20
Message-ID: 8b37e2e5.0312051351.4045b4e@posting.google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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(at)shadovitz(dot)com)
as well as to the list.

Thanks.
-David

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Grace C. Unson 2003-12-06 05:05:18 Index not recognized
Previous Message Elielson Fontanezi 2003-12-05 19:18:54 Values like ''