Optimizer bug in UPDATE with subselect - Mailing list pgsql-bugs

From Ace
Subject Optimizer bug in UPDATE with subselect
Date
Msg-id 000501c2c238$1340b4c0$a4428a09@ASZEPCZYNSKI
Whole thread Raw
In response to Bug #880: COMMENT ON DATABASE depends on current database  (pgsql-bugs@postgresql.org)
Responses Re: Optimizer bug in UPDATE with subselect
List pgsql-bugs
I've upgraded my DB to 7.3.1 from 7.2. The following update causes the SEQ
SCAN instead of INDEX SCAN (in 7.2 there was no bug like that):

create table machines(
 i_sprzetx int,
mod char(10),
type char(30)
);

create table sprzetx(
  rowid int,
  ident char(50)
);

create index i_sprzetx on sprzetx(ident);

inserts....

vacuum analyze sprzetx;

update machines set i_sprzetx=(
    select g.rowid from sprzetx g
      where g.ident=( trim(f.type) || trim(f.mod) )
  );

When optimizer meets ANY expression int the query clause switches from INDEX
to SEQUENTIAL disregarding the expression is constant for row.

Helps ALTER COLUMN to machines, UPDATE to TRIM || TRIM but sure it's not
solution.



----------------------------------------------------------------------
Czego nie wykorzystujesz, procentuje! mBIZNES Konto i mBIZNES MAX.
Efektywne oprocentowanie 5.64% i 6.59%. > http://link.interia.pl/f16c0

pgsql-bugs by date:

Previous
From: pgsql-bugs@postgresql.org
Date:
Subject: Bug #880: COMMENT ON DATABASE depends on current database
Next
From: "Averk"
Date:
Subject: stored procedure namespace bug (critical) + COALECSE notice