pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Marty Scholes <marty@outputservices.com>
To: pgsql-performance@postgresql.org
Subject: Re: PostgreSQL caching
Date: Mon, 24 May 2004 16:52:02 -0600
Message-ID: <40B27C92.9000109@outputservices.com> (raw)

 > Hello Marty,
 >
 > MS> Is that a composite index?
 >
 > It is a regular btree index. What is a composite index?

My apologies.  A composite index is one that consists of multiple fields 
(aka multicolumn index).  The reason I ask is that it was spending 
almost half the time just searching bv_bookgenres, which seemed odd.

I may be speaking out of turn since I am not overly familiar with Pg's 
quirks and internals.

A composite index, or any index of a large field, will lower the number 
of index items stored per btree node, thereby lowering the branching 
factor and increasing the tree depth.  On tables with many rows, this 
can result in many more disk accesses for reading the index.  An index 
btree that is 6 levels deep will require at least seven disk accesses (6 
for the index, one for the table row) per row retrieved.

Not knowing the structure of the indexes, it's hard to say too much 
about it.  The fact that a 1993 row select from an indexed table took 
3.5 seconds caused me to take notice.

 > MS> I would be curious to see how it performs with an "IN" clause,
 > MS> which I would suspect would go quite a bit fasrer.
 >
 > Actually it reached 20s before I canceled it... Here's the explain:

I believe that.  The code I posted had a nasty join bug.  If my math is 
right, the query was trying to return 1993*1993, or just under 4 million 
rows.

I didn't see the table structure, but I assume that the vote_avg and 
vote_count fields are in bv_bookgenres.  If no fields are actually 
needed from bv_bookgenres, then the query might be constructed in a way 
that only the index would be read, without loading any row data.

I think that you mentioned this was for a web app.  Do you actually have 
a web page that displays 2000 rows of data?

Good luck,
Marty




view thread (26+ messages)  latest in thread

Message-ID: <40B27C92.9000109@outputservices.com>
Permalink:  ../40B27C92.9000109@outputservices.com/
Also on:    postgresql.org/message-id/40B27C92.9000109@outputservices.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: marty@outputservices.com
  Subject: Re: PostgreSQL caching
  In-Reply-To: <40B27C92.9000109@outputservices.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