Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WJQN9-00017l-Fk for pgsql-sql@arkaria.postgresql.org; Fri, 28 Feb 2014 16:33:15 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WJQN9-000391-04 for pgsql-sql@arkaria.postgresql.org; Fri, 28 Feb 2014 16:33:15 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WJQN8-00038u-Bg for pgsql-sql@postgresql.org; Fri, 28 Feb 2014 16:33:14 +0000 Received: from sam.nabble.com ([216.139.236.26]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WJQN5-00012d-DI for pgsql-sql@postgresql.org; Fri, 28 Feb 2014 16:33:14 +0000 Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1WJQN3-0003PK-6R for pgsql-sql@postgresql.org; Fri, 28 Feb 2014 08:33:09 -0800 Date: Fri, 28 Feb 2014 08:33:09 -0800 (PST) From: David Johnston To: pgsql-sql@postgresql.org Message-ID: <1393605189189-5794066.post@n5.nabble.com> In-Reply-To: <1083597622.602688.1393603940121.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> <1393601978985-5794056.post@n5.nabble.com> <1083597622.602688.1393603940121.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: 1.8 (+) 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 > customer may have various payment channels during the time... new-ness is > not impacted by the channel, it does not matter from which channel, all > customer_id occurences count (in determined filtration criteria, e.g. > town, service, subservice) > > and there are also other filtration and grouping criteria (town, service, > subservice) and user of reporting tool should have possibility to select > from those... there are dozens of services and subservices, cca 4 payment > channels, dozens of towns... therefore preprocessing through materialized > view (if I understand your suggestion correctly), would contain a lot of > combinations, it seems quite complex for me in these circumstances > > I also considered WITH (CTEs) previously, I will rethink it yet, after > these your recommendations I'm not sure what you are going for since you keep adding additional criteria/constraints to your problem. At this point you are faced with a series of trade-offs between caching, speed, and flexibilty, complexity. I would suggest you break up your requirements into smaller pieces and not go looking for some kind of magic bullet that will solve all your problems in a single query. It likely does not exist. I would also suggest that you look into resources on data warehousing and the star schema; doing what you are trying directly within the OLTP is probably not the best solution - especially not on front-end servers. My experience in this area is thin but maybe someone else can make some suggestions and/or provide some useful resource links. David J. -- View this message in context: http://postgresql.1045698.n5.nabble.com/how-to-effectively-SELECT-new-customers-tp5793867p5794066.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