dynamic date

From: Tomasz Myrta <jasiek(at)lamer(dot)pl>
To: pgsql-bugs(at)postgresql(dot)org
Subject: dynamic date
Date: 2001-09-11 09:55:15
Message-ID: 3B9DDF83.884C7509@lamer.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I have something like this:

billy=# EXPLAIN SELECT * from kursy where id_trasy=1 and
data_kursu=date('2001-12-12');
NOTICE: QUERY PLAN:
Index Scan using pp on kursy (cost=0.00..51.55 rows=1 width=18)

billy=# EXPLAIN SELECT * from kursy where id_trasy=1
and data_kursu='2001-12-12';
NOTICE: QUERY PLAN:
Index Scan using pp on kursy (cost=0.00..2.02 rows=1 width=18)

Why the first expression is 25 times slower?
I suppose, that planner thinks, that date('2001-12-12') is a dynamic
variable - is it true? I found this problem when i had to add date and
integer. Little "iscachable" function helped me, but I still don't know
why it happened.

CREATE FUNCTION date_sum(date,integer) returns date AS'
BEGIN
return $1+$2;
END;
'LANGUAGE 'plpgsql' WITH (iscachable);

Browse pgsql-bugs by date

  From Date Subject
Next Message pgsql-bugs 2001-09-11 11:23:45 Bug #447: lost connection to back end
Previous Message pgsql-bugs 2001-09-11 07:34:52 Bug #446: Windows 2000 ODBC driver(7.01.0006) crashes.