X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8015732B239 for ; Sat, 9 Oct 2004 04:49:32 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 50511-03 for ; Sat, 9 Oct 2004 03:49:28 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id C0EE532AC6D for ; Sat, 9 Oct 2004 04:49:27 +0100 (BST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id i993nNpv023597; Fri, 8 Oct 2004 23:49:23 -0400 (EDT) To: "C. Bensend" Cc: pgsql-sql@postgresql.org Subject: Re: Impact of foreign keys on a simple count(*) ? 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> Comments: In-reply-to "C. Bensend" message dated "Fri, 08 Oct 2004 22:37:33 -0500" Date: Fri, 08 Oct 2004 23:49:23 -0400 Message-ID: <23596.1097293763@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200410/56 X-Sequence-Number: 19159 "C. Bensend" 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