pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Craig James <craig_james@emolecules.com>
To: Alvaro Herrera <alvherre@commandprompt.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: LIKE search and performance
Date: Thu, 24 May 2007 15:08:16 -0700
Message-ID: <46560CD0.404@emolecules.com> (raw)
In-Reply-To: <20070524214654.GR4320@alvh.no-ip.org>
References: <009501c79d4c$445428f0$0b00a8c0@mpsro.dom>
	<88daf38c0705230905u1a981102k691b47bd36011a80@mail.gmail.com>
	<4655DE75.4080506@mansionfamily.plus.com>
	<4655E64B.5050503@hagander.net>
	<4655FB8A.1040707@mansionfamily.plus.com>
	<1180040560.31471.262.camel@archimedes>
	<46560264.2020406@emolecules.com>
	<20070524214654.GR4320@alvh.no-ip.org>

Alvaro Herrera wrote:
 >> Just out of curiosity: Does Postgress store a duplicate of the data in the 
>> index, even for long strings?  I thought indexes only had to store the 
>> string up to the point where there was no ambiguity, for example, if I have 
>> "missing", "mississippi" and "misty", the index only needs "missin", 
>> "missis" and "mist" in the actual index.
> 
> What would happen when you inserted a new tuple with just "miss"?  You
> would need to expand all the other tuples in the index.

That's right.  This technique used by some index implementations is a tradeoff between size and update speed.  Most words in most natural languages can be distinguished by the first few characters.  The chances of having to modify more than a few surrounding nodes when you insert "miss" is small, so some implementations choose this method.  Other implementations choose to store the full string.  I was just curious which method Postgres uses.

Craig




view thread (29+ messages)  latest in thread

Message-ID: <46560CD0.404@emolecules.com>
Permalink:  ../46560CD0.404@emolecules.com/
Also on:    postgresql.org/message-id/46560CD0.404@emolecules.com

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: craig_james@emolecules.com, alvherre@commandprompt.com
  Subject: Re: LIKE search and performance
  In-Reply-To: <46560CD0.404@emolecules.com>

* 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