Sophie

Sophie

distrib > Mandriva > current > i586 > media > main-updates > by-pkgid > fc62ce67f262cdcd253dc7f849ce3223 > files > 240

postgresql8.4-docs-8.4.12-0.1mdv2010.2.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>Implementation</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.4.12 Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="GIN Indexes"
HREF="gin.html"><LINK
REL="PREVIOUS"
TITLE="Extensibility"
HREF="gin-extensibility.html"><LINK
REL="NEXT"
TITLE="GIN tips and tricks"
HREF="gin-tips.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="2012-05-31T23:30:11"></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.4.12 Documentation</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="gin-extensibility.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="gin.html"
>Fast Backward</A
></TD
><TD
WIDTH="60%"
ALIGN="center"
VALIGN="bottom"
>Chapter 52. GIN Indexes</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="top"
><A
HREF="gin.html"
>Fast Forward</A
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="top"
><A
HREF="gin-tips.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="GIN-IMPLEMENTATION"
>52.3. Implementation</A
></H1
><P
>  Internally, a <ACRONYM
CLASS="ACRONYM"
>GIN</ACRONYM
> index contains a B-tree index
  constructed over keys, where each key is an element of the indexed value
  (a member of an array, for example) and where each tuple in a leaf page is
  either a pointer to a B-tree over heap pointers (PT, posting tree), or a
  list of heap pointers (PL, posting list) if the list is small enough.
 </P
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="GIN-FAST-UPDATE"
>52.3.1. GIN fast update technique</A
></H2
><P
>   Updating a <ACRONYM
CLASS="ACRONYM"
>GIN</ACRONYM
> index tends to be slow because of the
   intrinsic nature of inverted indexes: inserting or updating one heap row
   can cause many inserts into the index (one for each key extracted
   from the indexed value). As of <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> 8.4,
   <ACRONYM
CLASS="ACRONYM"
>GIN</ACRONYM
> is capable of postponing much of this work by inserting
   new tuples into a temporary, unsorted list of pending entries.
   When the table is vacuumed, or if the pending list becomes too large
   (larger than <A
HREF="runtime-config-resource.html#GUC-WORK-MEM"
>work_mem</A
>), the entries are moved to the
   main <ACRONYM
CLASS="ACRONYM"
>GIN</ACRONYM
> data structure using the same bulk insert
   techniques used during initial index creation.  This greatly improves
   <ACRONYM
CLASS="ACRONYM"
>GIN</ACRONYM
> index update speed, even counting the additional
   vacuum overhead.  Moreover the overhead can be done by a background
   process instead of in foreground query processing.
  </P
><P
>   The main disadvantage of this approach is that searches must scan the list
   of pending entries in addition to searching the regular index, and so
   a large list of pending entries will slow searches significantly.
   Another disadvantage is that, while most updates are fast, an update
   that causes the pending list to become <SPAN
CLASS="QUOTE"
>"too large"</SPAN
> will incur an
   immediate cleanup cycle and thus be much slower than other updates.
   Proper use of autovacuum can minimize both of these problems.
  </P
><P
>   If consistent response time is more important than update speed,
   use of pending entries can be disabled by turning off the
   <TT
CLASS="LITERAL"
>FASTUPDATE</TT
> storage parameter for a
   <ACRONYM
CLASS="ACRONYM"
>GIN</ACRONYM
> index.  See <A
HREF="sql-createindex.html"
><I
>CREATE INDEX</I
></A
> for details.
  </P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="GIN-PARTIAL-MATCH"
>52.3.2. Partial match algorithm</A
></H2
><P
>   GIN can support <SPAN
CLASS="QUOTE"
>"partial match"</SPAN
> queries, in which the query
   does not determine an exact match for one or more keys, but the possible
   matches fall within a reasonably narrow range of key values (within the
   key sorting order determined by the <CODE
CLASS="FUNCTION"
>compare</CODE
> support method).
   The <CODE
CLASS="FUNCTION"
>extractQuery</CODE
> method, instead of returning a key value
   to be matched exactly, returns a key value that is the lower bound of
   the range to be searched, and sets the <TT
CLASS="LITERAL"
>pmatch</TT
> flag true.
   The key range is then searched using the <CODE
CLASS="FUNCTION"
>comparePartial</CODE
>
   method.  <CODE
CLASS="FUNCTION"
>comparePartial</CODE
> must return zero for an actual
   match, less than zero for a non-match that is still within the range
   to be searched, or greater than zero if the index key is past the range
   that could match.
  </P
></DIV
></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="gin-extensibility.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="gin-tips.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Extensibility</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="gin.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>GIN tips and tricks</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>