Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WJPXM-0007h7-Sr for pgsql-sql@arkaria.postgresql.org; Fri, 28 Feb 2014 15:39:45 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WJPXM-0001Iw-CD for pgsql-sql@arkaria.postgresql.org; Fri, 28 Feb 2014 15:39:44 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WJPXK-0001HD-N5 for pgsql-sql@postgresql.org; Fri, 28 Feb 2014 15:39:42 +0000 Received: from sam.nabble.com ([216.139.236.26]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WJPXI-0007br-ED for pgsql-sql@postgresql.org; Fri, 28 Feb 2014 15:39:42 +0000 Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1WJPXG-0001bi-W7 for pgsql-sql@postgresql.org; Fri, 28 Feb 2014 07:39:39 -0800 Date: Fri, 28 Feb 2014 07:39:38 -0800 (PST) From: David Johnston To: pgsql-sql@postgresql.org Message-ID: <1393601978985-5794056.post@n5.nabble.com> In-Reply-To: <976203811.595346.1393587926835.JavaMail.root@mobiletech.sk> References: <1001132708.567696.1393510818245.JavaMail.root@mobiletech.sk> <1393513774376-5793882.post@n5.nabble.com> <976203811.595346.1393587926835.JavaMail.root@mobiletech.sk> Subject: Re: how to effectively SELECT new "customers" MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: 4.5 (++++) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org Jan Ostrochovsky wrote > materialized view could be part of that solution, when we will have the > right query and uprgade from 9.0 to 9.3 (as I see it: > http://www.postgresql.org/docs/9.3/static/rules-materializedviews.html)... 9.3 adds materialized views syntax and functionality directly into PostgreSQL but you can "roll your own" in any version and that is what I would suggest. I would probably focus on getting a single reporting period to execute performantly and just use a loop to build up the materialized view period-by-period. I don't know how you want to go about dealing with your payment channel since it depends on whether a customer can make use of more than one and whether their "new-ness" is impacted by such. Incorporating other data is as simple as building the different pieces and joining them together into a final output; usually through a series of CTEs/WITH sub-queries. David J. -- View this message in context: http://postgresql.1045698.n5.nabble.com/how-to-effectively-SELECT-new-customers-tp5793867p5794056.html Sent from the PostgreSQL - sql mailing list archive at Nabble.com. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql