Re: [GENERAL] Partitioning - Mailing list pgsql-general

From George Neuner
Subject Re: [GENERAL] Partitioning
Date
Msg-id 96thncd3iicb6g2nhd30fiq0d213digbab@4ax.com
Whole thread Raw
In response to [GENERAL] Partitioning  (Krithika Venkatesh <krithikavenkatesh31@gmail.com>)
List pgsql-general
On Tue, 25 Jul 2017 18:21:43 +0530, Krithika Venkatesh
<krithikavenkatesh31@gmail.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

pgsql-general by date:

Previous
From: Dmitry Lazurkin
Date:
Subject: Re: [GENERAL] Perfomance of IN-clause with many elements and possible solutions
Next
From: Peter Geoghegan
Date:
Subject: Re: [GENERAL] Indexes being ignored after upgrade to 9.5