Someone offlist reported query slowness because we don't convert
function calls with all-constant parameters to be a constants before we
start a sequential scan:

        EXPLAIN SELECT * FROM test WHERE 
                x >= to_date('2001-01-01', 'YYYY-MM-DD') AND 
                x <= to_date('2001-01-01', 'YYYY-MM-DD');
        
                                                                  QUERY PLAN
        
-------------------------------------------------------------------------------------------------------------------------------
        
         Seq Scan on test  (cost=0.00..58.00 rows=12 width=4)
           Filter: ((x >= to_date('2001-01-01'::text, 'YYYY-MM-DD'::text)) AND
        (x <= to_date('2001-01-01'::text, 'YYYY-MM-DD'::text)))
        (2 rows)

Notice the to_date()'s were not converted to constants in EXPLAIN so
they are evaluated for every row.  to_date() is marked STABLE.

Is this something we should improve?

-- 
  Bruce Momjian  <br...@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to