Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 38F2DB60899 for ; Wed, 1 Jun 2011 20:54:43 -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 23276-01 for ; Wed, 1 Jun 2011 23:54:36 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-vw0-f46.google.com (mail-vw0-f46.google.com [209.85.212.46]) by mail.postgresql.org (Postfix) with ESMTP id 32EA0B607FE for ; Wed, 1 Jun 2011 20:54:36 -0300 (ADT) Received: by vws1 with SMTP id 1so270350vws.19 for ; Wed, 01 Jun 2011 16:54:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=iW3ljT8REB2BIhkomaRaFdwMzJpk/fHNg9dpMlccFD4=; b=YpTEWFUB35AnB5G1TOGC40jZIyJBuF2j84h6c2yjahW3DAfTp9ZpBaXwkgHRRuq/bI +hq+l/U2l7oeL/C5TI+SQoCSxYwSjBKwKqZjM7SzayDVUhNp0tfCSYYTNPgvUmWDr3Rf 1GZb0MFrQuycN/fDo2YVQibHqw76IlAM4NMVI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=KAbheVyUNbzsIQf8Kqp+XzCoGH84VuKSsz6vGy/6B/Gp03YgN5nHqRbtw0/OPqYfAJ 4imkgJvMPM3IX/N0JIABsNSe7Q2OW2lh0zDe2g0vkp01KM+MZd2peD3pQlZJt2+HdgAY d9LxiQ4tbhGIlT8pGJ0M4NnZz37Rxk9BJyonI= MIME-Version: 1.0 Received: by 10.52.174.49 with SMTP id bp17mr94112vdc.243.1306972475895; Wed, 01 Jun 2011 16:54:35 -0700 (PDT) Received: by 10.52.101.137 with HTTP; Wed, 1 Jun 2011 16:54:35 -0700 (PDT) Date: Wed, 1 Jun 2011 19:54:35 -0400 Message-ID: Subject: CLUSTER versus a dedicated table From: Robert James To: pgsql-performance@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.888 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RFC_ABUSE_POST=0.001, T_TO_NO_BRKTS_FREEMAIL=0.01 X-Spam-Level: X-Archive-Number: 201106/10 X-Sequence-Number: 43943 Hi. I'm interested in understanding the differences between CLUSTERing a table and making a dedicated one. We have a table with about 1 million records. On a given day, only about 1% of them are of interest. That 1% changes every day (it's WHERE active_date = today), and so we index and cluster on it. Even so, the planner shows a very large cost for the Index Scan: about 3500. If I instead do a SELECT INTO temp_table FROM big_table WHERE active_date = today, and then do SELECT * FROM temp_table, I get a planned cost of 65. Yet, the actual time for both queries is almost identical. Questions: 1. Why is there such a discrepancy between the planner's estimate and the actual cost? 2. In a case like this, will I in general see a performance gain by doing a daily SELECT INTO and then querying from that table? My ad hoc test doesn't indicate I would (despite the planner's prediction), and I'd rather avoid this if it won't help. 3. In general, does CLUSTER provide all the performance benefits of a dedicated table? If it doesn't, what does it lack? Thank you.