Re: Partitioning

From: George Neuner <gneuner2(at)comcast(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Partitioning
Date: 2017-07-26 20:22:03
Message-ID: 96thncd3iicb6g2nhd30fiq0d213digbab@4ax.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 25 Jul 2017 18:21:43 +0530, Krithika Venkatesh
<krithikavenkatesh31(at)gmail(dot)com> 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

In response to

  • Partitioning at 2017-07-25 12:51:43 from Krithika Venkatesh

Browse pgsql-general by date

  From Date Subject
Next Message Peter Geoghegan 2017-07-26 21:05:50 Re: Indexes being ignored after upgrade to 9.5
Previous Message Dmitry Lazurkin 2017-07-26 19:14:21 Re: Perfomance of IN-clause with many elements and possible solutions