X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 1C1AB9FB3D6 for ; Tue, 12 Sep 2006 16:23:28 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 73721-01 for ; Tue, 12 Sep 2006 19:19:50 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.telefor.hu (mail.telefor.hu [193.68.53.97]) by postgresql.org (Postfix) with ESMTP id 5E9069FB329 for ; Tue, 12 Sep 2006 16:11:16 -0300 (ADT) Received: from telefor-server.int.telefor-new.hu (telefor-server.int.telefor-new.hu [10.0.20.100]) by mail.telefor.hu (Postfix) with ESMTP id CA4DB1C042; Tue, 12 Sep 2006 21:11:11 +0200 (CEST) Received: from [10.0.20.33] ([10.0.20.33]) by telefor-server.int.telefor-new.hu with Microsoft SMTPSVC(6.0.3790.1830); Tue, 12 Sep 2006 21:06:03 +0200 Message-ID: <4507051B.1050800@telefor.hu> Date: Tue, 12 Sep 2006 21:06:03 +0200 From: =?UTF-8?B?TWV6ZWkgWm9sdMOhbg==?= Organization: Telefor Kft. User-Agent: Thunderbird 1.5.0.5 (Windows/20060719) MIME-Version: 1.0 To: Aaron Bono CC: pgsql-sql@postgresql.org Subject: Re: Two optimization questions References: <45068ABE.8040907@telefor.hu> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 12 Sep 2006 19:06:03.0732 (UTC) FILETIME=[7E369140:01C6D69E] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200609/85 X-Sequence-Number: 26296 Aaron Bono wrote: > You could split it into sub-queries but would that make the > performance better or worse? I guess it depends on how much data is > there, and what frequency you have ot the event_type's but indexing > the event_type column would help. This may be worth a try - use > EXPLAIN to see which is better. > Yep, I tought of that, but the solution with having is faster now. I think it is because about 30% of the rows are selected in the subquery now. Later we will have more records, and the subselect should select only about 1-2% of the rows. At that time, I think your solution will be faster. > Questions like this come up frequently and there are some nice solutions: > > See if this gives you some insight: > > select > '2006-01-15'::date + s.inc > from > generate_series(0, ('2006-02-20'::date - > '2006-01-15'::date)::integer) as s(inc) Sup, that's just what I needed. Thank you. Zizi