X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 7A720D1B45B for ; Fri, 5 Dec 2003 21:59:05 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 36768-05 for ; Fri, 5 Dec 2003 17:58:36 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id B31A1D1B43A for ; Fri, 5 Dec 2003 17:58:33 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id hB5LwRbI062833 for ; Fri, 5 Dec 2003 21:58:27 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id hB5LpDhK062041 for pgsql-sql@postgresql.org; Fri, 5 Dec 2003 21:51:13 GMT From: david_shadovitz@xontech.com (David Shadovitz) X-Newsgroups: comp.databases.postgresql.sql Subject: Fetch a single record Date: 5 Dec 2003 13:51:20 -0800 Organization: http://groups.google.com Lines: 20 Message-ID: <8b37e2e5.0312051351.4045b4e@posting.google.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: groups-abuse@google.com To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200312/68 X-Sequence-Number: 16234 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