Skip site navigation (1) Skip section navigation (2)

dynamic-static date

From: Tomasz Myrta <jasiek(at)lamer(dot)pl>
To: pgsql-bugs(at)postgresql(dot)org
Subject: dynamic-static date
Date: 2001-09-12 12:22:18
Message-ID: 3B9F537A.9230A1@lamer.pl (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-hackers
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);



Responses

pgsql-hackers by date

Next:From: Patrick WelcheDate: 2001-09-12 12:29:27
Subject: Re: backend hba.c prob
Previous:From: Peter EisentrautDate: 2001-09-12 12:07:40
Subject: Re: syslog by default?

pgsql-bugs by date

Next:From: pgsql-bugsDate: 2001-09-12 15:17:39
Subject: Bug #449: there is a problem with foreign key
Previous:From: pie yvesDate: 2001-09-12 10:28:19
Subject: problem with foreign key

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group