pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: C. Bensend <benny@bennyvision.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Impact of foreign keys on a simple count(*) ?
Date: Fri, 08 Oct 2004 23:49:23 -0400
Message-ID: <23596.1097293763@sss.pgh.pa.us> (raw)
In-Reply-To: <51319.63.227.74.41.1097293075.squirrel@63.227.74.41>
References: <51319.63.227.74.41.1097293075.squirrel@63.227.74.41>

"C. Bensend" <benny@bennyvision.com> writes:
>    Is it the addition of the multiple foreign keys that is slowing this
> down so much?

Foreign keys have zero, nada, zilch to do with the performance of
count(*).  The only plausible theory I can think of for the performance
difference is that in your "new" database the table has been through
several mass updates, leading to a whole lot of dead rows and a much
larger physical table size to scan through.  I'd suggest a VACUUM
VERBOSE on both old and new copies of the table to get an idea of the
relative physical sizes.  You might need a VACUUM FULL to get the new
table back down to a reasonable size...

			regards, tom lane



view thread (3+ messages)  latest in thread

Message-ID: <23596.1097293763@sss.pgh.pa.us>
Permalink:  ../23596.1097293763@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/23596.1097293763@sss.pgh.pa.us

 · 

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-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, benny@bennyvision.com
  Subject: Re: Impact of foreign keys on a simple count(*) ?
  In-Reply-To: <23596.1097293763@sss.pgh.pa.us>

* 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