Thread: custom index

custom index

From
michael uwe maier
Date:
Hi ,

  i want to develop an index for a special problem.
  The postgres docs shows the necessary bits in
  http://www.postgresql.org/docs/8.4/interactive/indexam.html
  especially paragraph 50.2 "Index Access Method Functions".

  Now my question: can i use the (documented) Server Programming
  interface within this functions (e.g. SPI_exec within ambuild)
  or do i need to use other (possibly undocumented) functions.
  Background: The index needs some metadata which can be created
  within "normal" tables. Otherwise this information must be built
  within the index.

  And as an appendix to my question: Are there any (simple) examples
  for custom indexes ?

greetings
 uwe



Re: custom index

From
Simon Riggs
Date:
On Mon, 2010-03-01 at 14:52 +0100, michael uwe maier wrote:

>   i want to develop an index for a special problem.
>   The postgres docs shows the necessary bits in
>   http://www.postgresql.org/docs/8.4/interactive/indexam.html
>   especially paragraph 50.2 "Index Access Method Functions".
>
>   Now my question: can i use the (documented) Server Programming
>   interface within this functions (e.g. SPI_exec within ambuild)
>   or do i need to use other (possibly undocumented) functions.
>   Background: The index needs some metadata which can be created
>   within "normal" tables. Otherwise this information must be built
>   within the index.

Yes. There isn't any other way to pass user-defined metadata to an index
at build time. "Storage parameters" exist, but these aren't user
extensible, yet.

Using SQL within anything other than ambuild would cause the index to be
volatile and likely to be non-useful.

>   And as an appendix to my question: Are there any (simple) examples
>   for custom indexes ?

Look at hash indexes.

That is somewhat simpler because of the lack of transaction logging.

--
 Simon Riggs           www.2ndQuadrant.com