Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id A6982B5DBC8 for ; Fri, 7 Oct 2011 07:24:27 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 16939-05 for ; Fri, 7 Oct 2011 10:24:21 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from kolab.mnc.ch (62-2-77-205.static.cablecom.ch [62.2.77.205]) by mail.postgresql.org (Postfix) with ESMTP id 45F33B5DBC4 for ; Fri, 7 Oct 2011 07:24:20 -0300 (ADT) Received: from localhost (kolab.op.lan [127.0.0.1]) by kolab.mnc.ch (Postfix) with ESMTP id E48106D0CB; Fri, 7 Oct 2011 12:24:18 +0200 (CEST) X-Virus-Scanned: by amavisd-new at mnc.ch Received: from kolab.mnc.ch ([127.0.0.1]) by localhost (kolab.mnc.ch [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jBXLb6w+o47M; Fri, 7 Oct 2011 12:24:18 +0200 (CEST) Received: from localhost (kolab.op.lan [127.0.0.1]) by kolab.mnc.ch (Postfix) with ESMTP id 28B666E1AA; Fri, 7 Oct 2011 12:24:18 +0200 (CEST) Received: from gc.localdomain (62-2-77-204.static.cablecom.ch [62.2.77.204]) by kolab.mnc.ch (Postfix) with ESMTP id 17EA86D0CB; Fri, 7 Oct 2011 12:24:18 +0200 (CEST) Received: by gc.localdomain (Postfix, from userid 500) id DE73518A21B; Fri, 7 Oct 2011 12:24:17 +0200 (CEST) To: Giovanni Mancuso Cc: pgsql-performance@postgresql.org Subject: Re: Performance problem with a table with 38928077 record References: <4E8ECEB7.4080800@babel.it> From: Guillaume Cottenceau X-Hashcash: 1:21:111007:gmancuso@babel.it::i7JnOvI1d+c14czZ:000000000000000000000000000000000000000000009oe9 X-Hashcash: 1:21:111007:pgsql-performance@postgresql.org::sbvPq+4gJbVBwnP6:000000000000000000000000000000gPM Date: Fri, 07 Oct 2011 12:24:17 +0200 In-Reply-To: <4E8ECEB7.4080800@babel.it> (Giovanni Mancuso's message of "Fri\, 07 Oct 2011 12\:04\:39 +0200") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201110/69 X-Sequence-Number: 45291 Giovanni Mancuso writes: > select count(*) from dm_object_perm; >   count   > ---------- >  38'928'077 > (1 row) [...] > If i run "explain analyze select * from dm_object_perm;" it goes on for many > hours. Almost 39 million records is not small, especially if you run on poor hardware[1], poor configuration[2], poor database optimization[3], bloat[4], or a combination of these. [1] you could tell what hardware you use [2] you could report if your DB configuration is tuned/good [3] you could report if the DB is regularly analyzed/vacuumed [4] you could try a VACUUM FULL or CLUSTER and/or REINDEX on your large table(s) if you suspect answer to [3] is "no" - warning, these block some/all DB operations while running, and they will probably run for long in your situation > If i try to execute a left join: "SELECT dm_object.id FROM dm_object LEFT JOIN > dm_object_perm ON dm_object.id = dm_object_perm.object_id;" my db is unusable. EXPLAIN on this query would probably tell you PG has quite some work to do to produce the result. > how can I fix this? I'm wondering if your DB design (storing almost all "object x account" combinations in object_perm) is optimal. -- Guillaume Cottenceau