Re: Type casting and indexes
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: "David Olbersen" <DOlbersen@stbernard.com>
Cc: pgsql-performance@postgresql.org
Date: 2003-05-08T16:25:07Z
Lists: pgsql-performance
"David Olbersen" <DOlbersen@stbernard.com> writes: > So it seems that the type conversion is killing the use of the index, even though the type conversion has to happen for the condition to be tested. Seems like I just answered this yesterday ;-) Note the difference in the number of estimated rows in the two explains. The reason is that the timestamptz conversion is not a constant and so the planner can't get a good estimate of the number of rows that will satisfy it. (And the reason it's not a constant is that it depends on SET TIMEZONE.) Bottom line: declare the constant correctly. Or at least don't gratuitously cast it to the wrong thing. regards, tom lane