Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: FOR UPDATE lock problem ?


  • From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
  • To: REYNAUD Jean-Samuel <reynaud(at)elma(dot)fr>
  • Cc: pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
  • Subject: Re: FOR UPDATE lock problem ?
  • Date: Tue, 25 Apr 2006 11:47:19 -0400
  • Message-id: <19763(dot)1145980039(at)sss(dot)pgh(dot)pa(dot)us>

REYNAUD Jean-Samuel <reynaud(at)elma(dot)fr> writes:
> test=# explain select s.id_session from users u, sessions s where
> to_date IS NULL and u.id_user = s.id_user;
>                                        QUERY PLAN
> -----------------------------------------------------------------------------------------
>  Nested Loop  (cost=0.00..6.85 rows=1 width=4)
>    ->  Index Scan using idx_session_null on sessions s  (cost=0.00..1.01
> rows=1 width=8)
>    ->  Index Scan using users_pkey on users u  (cost=0.00..5.82 rows=1
> width=4)
>          Index Cond: (u.id_user = "outer".id_user)
> (4 rows)

> If I remove the idx_session_null index the problem disappears.

Interesting example.  The planner is assuming that it need not
explicitly check the to_date IS NULL condition as a plan filter
condition since it is using a partial index, but apparently in the case
of SELECT FOR UPDATE queries we need to check anyway so that
EvalPlanQual will work properly.  Or maybe partial-index predicates
ought to be added to the EvalPlanQual mechanism.

			regards, tom lane



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group