pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
coercing int to bigint for indexing purposes
2+ messages / 2 participants
[nested] [flat]

* coercing int to bigint for indexing purposes
@ 2004-02-11 22:38  Mark Harrison <mh@pixar.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Mark Harrison @ 2004-02-11 22:38 UTC (permalink / raw)
  To: pgsql-performance

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




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: coercing int to bigint for indexing purposes
@ 2004-02-11 23:24  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Mark Harrison <mh@pixar.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2004-02-11 23:24 UTC (permalink / raw)
  To: Mark Harrison <mh@pixar.com>; +Cc: pgsql-performance

Mark Harrison <mh@pixar.com> writes:
> Is there a way to automatically coerce an int into a bigint for
> indexing purposes?

This problem is fixed in CVS tip.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2004-02-11 23:24 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-02-11 22:38 coercing int to bigint for indexing purposes Mark Harrison <mh@pixar.com>
2004-02-11 23:24 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox