Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 5D3446340A4 for ; Thu, 20 May 2010 17:04:04 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 13018-06 for ; Thu, 20 May 2010 20:03:56 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id E15D3633153 for ; Thu, 20 May 2010 17:03:56 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id o4KK3snb007918; Thu, 20 May 2010 16:03:54 -0400 (EDT) To: David Jarvis cc: Thom Brown , pgsql-performance@postgresql.org Subject: Re: Optimize date query for large child tables: GiST or GIN? In-reply-to: References: <7143.1274382139@sss.pgh.pa.us> <7767.1274385170@sss.pgh.pa.us> Comments: In-reply-to David Jarvis message dated "Thu, 20 May 2010 12:58:16 -0700" Date: Thu, 20 May 2010 16:03:54 -0400 Message-ID: <7917.1274385834@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201005/123 X-Sequence-Number: 38707 David Jarvis writes: > What if I were to have the application pass in two sets of date ranges? > For the condition of Dec 22 to Mar 22: > Dec 22 would become: > - Dec 22 - Dec 31 > Mar 22 would become: > - Jan 1 - Mar 22 I think what you're essentially describing here is removing the OR from the query in favor of issuing two queries and then combining the results in the app. Yeah, you could do that, but one would hope that it isn't faster ;-) regards, tom lane