Skip site navigation (1) Skip section navigation (2)

Re: Optimizer internals

From: Mark Lewis <mark(dot)lewis(at)mir3(dot)com>
To: pgsql-performance(at)lusis(dot)org
Cc: PGSQL Performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Optimizer internals
Date: 2006-06-15 18:33:45
Message-ID: 1150396425.31200.66.camel@archimedes (view raw, whole thread or download thread mbox)
Lists: pgsql-performance
On Thu, 2006-06-15 at 14:05 -0400, John Vincent wrote:
> Now I've been told by our DBA that we should have been able to wholy
> satisfy that query via the indexes.

DB2 can satisfy the query using only indexes because DB2 doesn't do

Although MVCC is generally a win in terms of making the database easier
to use and applications less brittle, it also means that the database
must inspect the visibility information for each row before it can
answer a query.  For most types of queries this isn't a big deal, but
for count(*) type queries, it slows things down.

Since adding the visibility information to indexes would make them
significantly more expensive to use and maintain, it isn't done.
Therefore, each row has to be fetched from the main table anyway.

Since in this particular query you are counting all rows of the
database, PG must fetch each row from the main table regardless, so the
sequential scan is much faster because it avoids traversing the index
and performing random read operations.

-- Mark Lewis

In response to


pgsql-performance by date

Next:From: John VincentDate: 2006-06-15 18:46:11
Subject: Re: Optimizer internals
Previous:From: Zoltan BoszormenyiDate: 2006-06-15 18:19:10
Subject: Re: Precomputed constants?

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group