Received: from localhost (unknown [200.46.204.184]) by developer.postgresql.org (Postfix) with ESMTP id 578092E0035 for ; Tue, 1 Apr 2008 01:29:43 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 25004-09 for ; Tue, 1 Apr 2008 01:29:37 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by developer.postgresql.org (Postfix) with ESMTP id 2D99F2E002D for ; Tue, 1 Apr 2008 01:29:37 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m314TZcH020194; Tue, 1 Apr 2008 00:29:35 -0400 (EDT) To: "Robins Tharakan" cc: pgsql-performance@postgresql.org Subject: Re: Performance Implications of Using Exceptions In-reply-to: <36af4bed0803311926v20f9c0cbkbd2869232dc547a@mail.gmail.com> References: <7a4208ef0803311720s1dac8362gff2477d3dc534968@mail.gmail.com> <20080401005235.GM4999@tamriel.snowman.net> <36af4bed0803311923u67641f1w489acad42412fb3d@mail.gmail.com> <36af4bed0803311926v20f9c0cbkbd2869232dc547a@mail.gmail.com> Comments: In-reply-to "Robins Tharakan" message dated "Tue, 01 Apr 2008 07:56:31 +0530" Date: Tue, 01 Apr 2008 00:29:35 -0400 Message-ID: <20193.1207024175@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200804/1 X-Sequence-Number: 29494 "Robins Tharakan" writes: > Would it fine to consider that an UPDATE query that found no records to > update is (performance wise) the same as a SELECT query with the same WHERE > clause ? > As in, does an UPDATE query perform additional overhead even before it finds > the record to work on ? The UPDATE would fire BEFORE STATEMENT and AFTER STATEMENT triggers, if there are any. Also, it would take a slightly stronger lock on the table, which might result in blocking either the UPDATE itself or some concurrent query where a plain SELECT would not've. There might be some other corner cases I've forgotten. But in the basic case I think your assumption is correct. regards, tom lane