X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 619DBDAC31 for ; Mon, 24 Oct 2005 01:40:09 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 07486-02 for ; Mon, 24 Oct 2005 04:40:07 +0000 (GMT) Received: from mailbox.samurai.com (mailbox.samurai.com [205.207.28.82]) by svr1.postgresql.org (Postfix) with ESMTP id A86C7D6F13 for ; Mon, 24 Oct 2005 01:40:07 -0300 (ADT) Received: from localhost (mailbox.samurai.com [205.207.28.82]) by mailbox.samurai.com (Postfix) with ESMTP id D33B82395FC; Mon, 24 Oct 2005 00:40:07 -0400 (EDT) Received: from mailbox.samurai.com ([205.207.28.82]) by localhost (mailbox.samurai.com [205.207.28.82]) (amavisd-new, port 10024) with LMTP id 81309-01-10; Mon, 24 Oct 2005 00:40:06 -0400 (EDT) Received: from [192.168.1.103] (d226-86-55.home.cgocable.net [24.226.86.55]) by mailbox.samurai.com (Postfix) with ESMTP id 7701023946D; Mon, 24 Oct 2005 00:40:06 -0400 (EDT) Subject: Re: Using LIMIT 1 in plpgsql PERFORM statements From: Neil Conway To: Josh Berkus Cc: "Karl O. Pinc" , pgsql-performance@postgresql.org In-Reply-To: <200510232136.35790.josh@agliodbs.com> References: <1129957521l.27845l.2l@mofo> <200510231402.35612.josh@agliodbs.com> <1130114418l.8670l.2l@mofo> <200510232136.35790.josh@agliodbs.com> Content-Type: text/plain Date: Mon, 24 Oct 2005 00:40:10 -0400 Message-Id: <1130128810.8506.25.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at mailbox.samurai.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 required=5 tests=[none] X-Spam-Level: X-Archive-Number: 200510/329 X-Sequence-Number: 15097 On Sun, 2005-23-10 at 21:36 -0700, Josh Berkus wrote: > SELECT id INTO v_check > FROM some_table ORDER BY id LIMIT 1; > > IF id > 0 THEN .... > > ... that says pretty clearly to code maintainers that I'm only interested in > finding out whether there's any rows in the table, while making sure I use > the index on ID. Why would you want to use the index on ID? -Neil