"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
forthe 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