Index selection bug - Mailing list pgsql-bugs

From Andriy I Pilipenko
Subject Index selection bug
Date
Msg-id Pine.BSF.4.21.0007260917440.51996-100000@bamby.marka.net.ua
Whole thread Raw
Responses Re: Index selection bug  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
============================================================================
                        POSTGRESQL BUG REPORT TEMPLATE
============================================================================


Your name               : Andriy I Pilipenko
Your email address      : bamby@marka.net.ua


System Configuration
---------------------
  Architecture (example: Intel Pentium)         : Intel Pentium

  Operating System (example: Linux 2.0.26 ELF)  : FreeBSD 3.x

  PostgreSQL version (example: PostgreSQL-7.0):   PostgreSQL-7.0.2

  Compiler used (example:  gcc 2.8.0)           : gcc 2.7.2.3


Please enter a FULL description of your problem:
------------------------------------------------

PostgreSQL refuses to use index if WHERE clause contains function call.
This problem exists in 6.5.3 also.


Please describe a way to repeat the problem.   Please try to provide a
concise reproducible example, if at all possible:
----------------------------------------------------------------------

Do following queries:

    create table t (f int);

    create index i on t (f);

    create function func() returns int as 'select 1' language 'sql';

    set enable_seqscan to 'off';

    explain select * from t where f = 1;

      Index Scan using i on t  (cost=0.00..2.01 rows=1 width=4)

    explain select * from t where f = func();

      Seq Scan on t  (cost=100000000.00..100000001.34 rows=1 width=4)


If you know how this problem might be fixed, list the solution below:
---------------------------------------------------------------------

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: [SQL] Index selection on a large table
Next
From: Tom Lane
Date:
Subject: Re: Index selection bug