On Tue, 25 Jul 2017 18:21:43 +0530, Krithika Venkatesh <krithikavenkatesh31@xxxxxxxxx> 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@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general