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 70E18D1B46C for ; Wed, 10 Dec 2003 00:12:03 +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 48757-01 for ; Tue, 9 Dec 2003 20:11:35 -0400 (AST) Received: from anchor-post-34.mail.demon.net (anchor-post-34.mail.demon.net [194.217.242.92]) by svr1.postgresql.org (Postfix) with ESMTP id 5BF31D1B487 for ; Tue, 9 Dec 2003 20:11:32 -0400 (AST) Received: from tmsl-adsl.demon.co.uk ([80.177.114.181] helo=bacon.tmsl.demon.co.uk) by anchor-post-34.mail.demon.net with esmtp (Exim 3.35 #1) id 1ATrx0-0009C9-0Y; Wed, 10 Dec 2003 00:11:34 +0000 Date: Wed, 10 Dec 2003 00:11:29 +0000 From: Paul Thomas To: David Shadovitz Cc: "pgsql-sql @ postgresql . org" Subject: Re: Fetch a single record Message-ID: <20031210001129.A30762@bacon> References: <8b37e2e5.0312051351.4045b4e@posting.google.com> Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=ISO-8859-1 In-Reply-To: <8b37e2e5.0312051351.4045b4e@posting.google.com>; from david_shadovitz@xontech.com on Fri, Dec 05, 2003 at 21:51:20 +0000 X-Mailer: Balsa 1.2.3 Lines: 24 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200312/76 X-Sequence-Number: 16242 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 | +------------------------------+---------------------------------------------+