Re: [NEWBIE] need help optimizing this query

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Dexter Tad-y <dexterbt1(at)my(dot)smart(dot)com(dot)ph>
Cc: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: [NEWBIE] need help optimizing this query
Date: 2004-03-10 15:08:58
Message-ID: 20040310070317.L27998@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 10 Mar 2004, Dexter Tad-y wrote:

> Greetings,
> I need help in optimizing this query:
>
> select a.id, b.transaction from test as a left join pg_locks as b on
> a.xmax = b.transaction where b.transaction is null;
>
> im using the query in obtaining records not locked by other
> transactions. any help is appreciated.

It's hard to say without knowing more about the size of a and explain
analyze output. On my 7.4 machine, using NOT IN rather than the left join
gives about a 2x speed increase on a 400k row table.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bjørn T Johansen 2004-03-10 15:18:06 Moving from 7.3.4 to 7.4.x?
Previous Message Bjørn T Johansen 2004-03-10 15:07:26 Backup of users and group?