Re: Performance Implications of Using Exceptions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Robins Tharakan" <tharakan(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Performance Implications of Using Exceptions
Date: 2008-04-01 04:29:35
Message-ID: 20193.1207024175@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

"Robins Tharakan" <tharakan(at)gmail(dot)com> 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

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2008-04-01 05:07:17 Re: POSIX file updates
Previous Message Robins Tharakan 2008-04-01 02:26:31 Re: Performance Implications of Using Exceptions