Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > media > main-testing > by-pkgid > bab02a23fa9f3df8d66a9a3231b50245 > files > 244

postgresql8.3-docs-8.3.6-2mdv2008.1.x86_64.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>Extensibility</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REV="MADE"
HREF="mailto:pgsql-docs@postgresql.org"><LINK
REL="HOME"
TITLE="PostgreSQL 8.3.6 Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="GiST Indexes"
HREF="gist.html"><LINK
REL="PREVIOUS"
TITLE="Introduction"
HREF="gist-intro.html"><LINK
REL="NEXT"
TITLE="Implementation"
HREF="gist-implementation.html"><LINK
REL="STYLESHEET"
TYPE="text/css"
HREF="stylesheet.css"><META
HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=ISO-8859-1"><META
NAME="creation"
CONTENT="2009-02-03T04:34:16"></HEAD
><BODY
CLASS="SECT1"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="5"
ALIGN="center"
VALIGN="bottom"
>PostgreSQL 8.3.6 Documentation</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="gist-intro.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="gist.html"
>Fast Backward</A
></TD
><TD
WIDTH="60%"
ALIGN="center"
VALIGN="bottom"
>Chapter 51. GiST Indexes</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="top"
><A
HREF="gist.html"
>Fast Forward</A
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="top"
><A
HREF="gist-implementation.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="GIST-EXTENSIBILITY"
>51.2. Extensibility</A
></H1
><P
>   Traditionally, implementing a new index access method meant a lot of
   difficult work.  It was necessary to understand the inner workings of the
   database, such as the lock manager and Write-Ahead Log.  The
   <ACRONYM
CLASS="ACRONYM"
>GiST</ACRONYM
> interface has a high level of abstraction,
   requiring the access method implementer to only implement the semantics of
   the data type being accessed.  The <ACRONYM
CLASS="ACRONYM"
>GiST</ACRONYM
> layer itself
   takes care of concurrency, logging and searching the tree structure.
 </P
><P
>   This extensibility should not be confused with the extensibility of the
   other standard search trees in terms of the data they can handle.  For
   example, <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> supports extensible B-trees
   and hash indexes. That means that you can use
   <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> to build a B-tree or hash over any
   data type you want. But B-trees only support range predicates
   (<TT
CLASS="LITERAL"
>&lt;</TT
>, <TT
CLASS="LITERAL"
>=</TT
>, <TT
CLASS="LITERAL"
>&gt;</TT
>),
   and hash indexes only support equality queries.
 </P
><P
>   So if you index, say, an image collection with a
   <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> B-tree, you can only issue queries
   such as <SPAN
CLASS="QUOTE"
>"is imagex equal to imagey"</SPAN
>, <SPAN
CLASS="QUOTE"
>"is imagex less
   than imagey"</SPAN
> and <SPAN
CLASS="QUOTE"
>"is imagex greater than imagey"</SPAN
>?
   Depending on how you define <SPAN
CLASS="QUOTE"
>"equals"</SPAN
>, <SPAN
CLASS="QUOTE"
>"less than"</SPAN
>
   and <SPAN
CLASS="QUOTE"
>"greater than"</SPAN
> in this context, this could be useful.
   However, by using a <ACRONYM
CLASS="ACRONYM"
>GiST</ACRONYM
> based index, you could create
   ways to ask domain-specific questions, perhaps <SPAN
CLASS="QUOTE"
>"find all images of
   horses"</SPAN
> or <SPAN
CLASS="QUOTE"
>"find all over-exposed images"</SPAN
>.
 </P
><P
>   All it takes to get a <ACRONYM
CLASS="ACRONYM"
>GiST</ACRONYM
> access method up and running
   is to implement seven user-defined methods, which define the behavior of
   keys in the tree. Of course these methods have to be pretty fancy to
   support fancy queries, but for all the standard queries (B-trees,
   R-trees, etc.) they're relatively straightforward. In short,
   <ACRONYM
CLASS="ACRONYM"
>GiST</ACRONYM
> combines extensibility along with generality, code
   reuse, and a clean interface.
  </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="gist-intro.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="gist-implementation.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Introduction</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="gist.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Implementation</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>