Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 08BF89D59D4 for ; Sat, 5 Nov 2011 11:40:38 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 83838-02 for ; Sat, 5 Nov 2011 14:40:32 +0000 (UTC) Received: from mx2.hub.org (mx2.hub.org [200.46.204.254]) by mail.postgresql.org (Postfix) with ESMTP id 2BDA89D59D1 for ; Sat, 5 Nov 2011 11:40:32 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from mail-vx0-f174.google.com (mail-vx0-f174.google.com [209.85.220.174]) by mx2.hub.org (Postfix) with ESMTP id B36941756362 for ; Sat, 5 Nov 2011 00:36:13 -0300 (ADT) Received: by vcbf1 with SMTP id f1so939272vcb.19 for ; Fri, 04 Nov 2011 20:35:34 -0700 (PDT) Received: by 10.52.97.35 with SMTP id dx3mr17679921vdb.2.1320464134315; Fri, 04 Nov 2011 20:35:34 -0700 (PDT) Received: from ayaki.localdomain (58-7-142-223.dyn.iinet.net.au. [58.7.142.223]) by mx.google.com with ESMTPS id bx19sm17066607vdb.2.2011.11.04.20.35.31 (version=SSLv3 cipher=OTHER); Fri, 04 Nov 2011 20:35:33 -0700 (PDT) Message-ID: <4EB4AEEC.6050408@ringerc.id.au> Date: Sat, 05 Nov 2011 11:35:08 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20110930 Thunderbird/7.0.1 MIME-Version: 1.0 To: Olgierd Michalak CC: "pgsql-sql@postgresql.org" Subject: Re: How to implement Aggregate Awareness? References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201111/22 X-Sequence-Number: 35995 On 11/05/2011 05:03 AM, Olgierd Michalak wrote: > Simply put, when Transparent (to the reporting tool) Aggregate Navigator > recognizes that a query would execute faster using aggregates, it > automatically rewrites the query so that the database hits the smaller > aggregates rather than larger detail tables upon which the small > aggregates are pre-computed. Assuming I understand what you want correctly: Before you could usefully do anything like that, I think you'd need to implement full support for materialized views. Once that's in place, the optimizer could potentially be enhanced to recognise queries against a base table and rewrite it to use a materialized view of the table when it sees that the query only touches data collected by the materialized view. Right now, there isn't really anything for query rewriting like this to /target/ . -- Craig Ringer