Is there a way to automatically coerce an int into a bigint for
indexing purposes?
We have a table with a bigint column that is an index.
For mi, there's no problem, since I now know to say
select * from foo where id = 123::bigint
but our casual users still say
select * from foo where id = 123
causing a sequential scan because the type of 123 is not
a bigint.
As you can see, there's nearly 4 orders of magnitude difference
in time, and we anticipate this will only get worse as our
tables increase in size:
LOG: duration: 0.861 ms statement: select * from big where id = 123123123123123;
LOG: duration: 6376.917 ms statement: select * from big where id = 123;
One thing I have considered is starting our id sequence at 5000000000
so that "real" queries will always be bigint-sized, but this seems
to me a bit of a hack.
Many TIA,
Mark
--
Mark Harrison
Pixar Animation Studios