Re: Impact of foreign keys on a simple count(*) ? - Mailing list pgsql-sql

From Tom Lane
Subject Re: Impact of foreign keys on a simple count(*) ?
Date
Msg-id 23596.1097293763@sss.pgh.pa.us
Whole thread Raw
In response to Impact of foreign keys on a simple count(*) ?  ("C. Bensend" <benny@bennyvision.com>)
Responses Re: Impact of foreign keys on a simple count(*) ?
List pgsql-sql
"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


pgsql-sql by date:

Previous
From: "C. Bensend"
Date:
Subject: Impact of foreign keys on a simple count(*) ?
Next
From: "C. Bensend"
Date:
Subject: Re: Impact of foreign keys on a simple count(*) ?