pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Btree index on varchar
2+ messages / 2 participants
[nested] [flat]

* Btree index on varchar
@ 2001-03-23 10:59 Alexaki Sofia <alexaki@ics.forth.gr>
  2001-03-23 16:29 ` Re: Btree index on varchar Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 2+ messages in thread

From: Alexaki Sofia @ 2001-03-23 10:59 UTC (permalink / raw)
  To: pgsql-sql

Hello,

I have a question for Btree indexes on a varchar field.
Does postgres (7.0.2) uses a special encoding when creating
Btree indexes on varchar??

Is it much more efficient to create indexes  on integer than
on strings with average length 30 chars??

Thank you in advance for your help

Regards
Sofia Alexaki




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

* Re: Btree index on varchar
  2001-03-23 10:59 Btree index on varchar Alexaki Sofia <alexaki@ics.forth.gr>
@ 2001-03-23 16:29 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2001-03-23 16:29 UTC (permalink / raw)
  To: Alexaki Sofia <alexaki@ics.forth.gr>; +Cc: pgsql-sql

Alexaki Sofia <alexaki@ics.forth.gr> writes:
> I have a question for Btree indexes on a varchar field.
> Does postgres (7.0.2) uses a special encoding when creating
> Btree indexes on varchar??

"Special encoding"?  No ... a varchar is a varchar.

> Is it much more efficient to create indexes  on integer than
> on strings with average length 30 chars??

It'd save some space and thereby save I/O time.  But I dunno about
"much" more efficient.  Figuring that there's a dozen or so bytes of
index-entry overhead in addition to the value itself, you might be
looking at a factor of 3 or so difference in index tuple size, hence
about a 3x savings in I/O for index scans; but that wouldn't translate
to anything like a factor of 3 for the total operation, since the number
of main-table tuples visited wouldn't change.  Try it and see, but I'd
guess that the net effect would be relatively small.

Really what you want to be asking yourself is which columns do you
need an index on for your query logic.  What datatype they are is a
minor consideration.

			regards, tom lane



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


end of thread, other threads:[~2001-03-23 16:29 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-03-23 10:59 Btree index on varchar Alexaki Sofia <alexaki@ics.forth.gr>
2001-03-23 16:29 ` 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