pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alexaki Sofia <alexaki@ics.forth.gr>
Cc: pgsql-sql@postgresql.org
Subject: Re: Btree index on varchar
Date: Fri, 23 Mar 2001 11:29:56 -0500
Message-ID: <18214.985364996@sss.pgh.pa.us> (raw)
In-Reply-To: <Pine.GSO.4.10.10103231252380.8056-100000@sappho.ics.forth.gr>
References: <Pine.GSO.4.10.10103231252380.8056-100000@sappho.ics.forth.gr>

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



view thread (2+ messages)

Message-ID: <18214.985364996@sss.pgh.pa.us>
Permalink:  ../18214.985364996@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/18214.985364996@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, alexaki@ics.forth.gr
  Subject: Re: Btree index on varchar
  In-Reply-To: <18214.985364996@sss.pgh.pa.us>
  References: <Pine.GSO.4.10.10103231252380.8056-100000@sappho.ics.forth.gr> <18214.985364996@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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