Re: Fetch a single record

From: greg(at)turnstep(dot)com
To: pgsql-sql(at)postgresql(dot)org
Cc: david_shadovitz(at)xontech(dot)com
Subject: Re: Fetch a single record
Date: 2003-12-10 00:45:40
Message-ID: e5b118baca8d81434e5616bfe8c0ddf1@biglumber.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


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

That's a strange request. If you really don't care what comes back, you
don't even need to query a table:

SELECT 1;

If you perhaps want the column names, query the system tables.

Otherwise the LIMIT 1 should be very fast, especially if you have no
ordering. Avoid the "SELECT *" if you don't need all the columns
for a little more speed.

- --
Greg Sabino Mullane greg(at)turnstep(dot)com
PGP Key: 0x14964AC8 200312091943

-----BEGIN PGP SIGNATURE-----

iD8DBQE/1mynvJuQZxSWSsgRAk0HAKDKTHglcodYw2G9j5Il60e96Vv/xwCfcZ6p
ffIBwsqFtqW0UABYttqzT3U=
=JV2a
-----END PGP SIGNATURE-----

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Paul Thomas 2003-12-10 00:52:56 Re: How to specify the beginning of the month in Postgres SQL syntax?
Previous Message Paul Thomas 2003-12-10 00:11:29 Re: Fetch a single record