Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1daSpC-0003MJ-HE for pgsql-general@arkaria.postgresql.org; Wed, 26 Jul 2017 20:22:30 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1daSpC-0001yr-0W for pgsql-general@arkaria.postgresql.org; Wed, 26 Jul 2017 20:22:30 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1daSpB-0001yf-A8 for pgsql-general@postgresql.org; Wed, 26 Jul 2017 20:22:29 +0000 Received: from [195.159.176.226] (helo=blaine.gmane.org) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1daSp8-0002wf-C4 for pgsql-general@postgresql.org; Wed, 26 Jul 2017 20:22:28 +0000 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1daSoo-0003nL-EE for pgsql-general@postgresql.org; Wed, 26 Jul 2017 22:22:06 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-general@postgresql.org From: George Neuner Subject: Re: Partitioning Date: Wed, 26 Jul 2017 16:22:03 -0400 Lines: 31 Message-ID: <96thncd3iicb6g2nhd30fiq0d213digbab@4ax.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@blaine.gmane.org X-Newsreader: Forte Agent 6.00/32.1186 X-Antivirus: Avast (VPS 170726-6, 07/26/2017), Outbound message X-Antivirus-Status: Clean X-Host-Lookup-Failed: Reverse DNS lookup failed for 195.159.176.226 (failed) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org On Tue, 25 Jul 2017 18:21:43 +0530, Krithika Venkatesh wrote: >I have a table that is partitioned on a numeric column (ID). > >Partitioning works when I query the table with no joins. > >SELECT * FROM TABLE A a WHERE ID IN (SELECT ID FROM TABLE B b WHERE >CREATED_TS = CURRENT_TIMESTAMP) > >Partitioning doesn't work when I do join. > >SELECT A.* FROM TABLE A a INNER JOIN TABLE B b ON a.ID = b.ID. > >Is there any other option that would work. > >Thanks in Advance.. The subselect is constraining the set of ID value(s) to be matched in A, which (at least potentially) permits identifying the relevant partition(s). The join must include all partitions of A because the set of ID values to be matched with B are not constrained. Also, the join query is not equivalent because it does not include the timestamp constraint on B. I don't think that will make any difference to the query plan ... AFAICS, it still needs to consider all partitions of A ... but it may improve performance. George -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general