Thread

  1. Index selection bug

    Andriy I Pilipenko <bamby@marka.net.ua> — 2000-07-26T06:24:49Z

    ============================================================================
                            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:
    ---------------------------------------------------------------------