<div><div>Hello,</div><div> </div><div>Yes, you are right; it seems that only 4 batches had data changes. However, the query also accessed other batches and then removed them again. What could be the reason for this and how can it be solved?</div><div> </div><div>Obviously, I would like to understand this situation better and learn the solution.</div><div> </div><div>I would be very grateful if you could help me.</div><div> </div><div>Thank you,</div><div> </div><div>Eşref Halıcıoğlu</div></div><div> </div><div>----------------</div><div>To: Eşref Halıcıoğlu (esref(dot)halicioglu(at)primeit(dot)com(dot)tr);</div><div>Cc: pgsql-general(at)lists(dot)postgresql(dot)org;</div><div>Subject: About PostgreSQL Query Plan;</div><div>13.01.2025, 19:56, "hubert depesz lubaczewski" <depesz(at)depesz(dot)com>:</div><blockquote><p>On Mon, Jan 13, 2025 at 07:48:09PM +0300, Eşref Halıcıoğlu wrote:</p><blockquote> Hello,<br /> <br /> Yes, you are right; this query is not a SELECT, it is an UPDATE query, there was a mistake in expressing it here. The columns I want<br /> to update here only operate on data from the last 3 months time interval.<br /> <br /> I am also sharing the EXPLAIN ANALYZE output of the relevant query below:<br /> <br /> Update on "TestTable1" t1 (cost=0.13..159114.84 rows=0 width=0) (actual time=0.007..0.008 rows=0 loops=1)<br /> Update on "PartitionTable_2020_10" t1</blockquote><p>… 61 lines removed …</p><blockquote> Update on "PartitionTable_2025_12" t1<br /> Update on "DefaultPartitionTable" t1<br /> -> Nested Loop (cost=0.13..159114.84 rows=1 width=53) (actual time=0.006..0.006 rows=0 loops=1)<br /> -> Seq Scan on "TempTable1" tmp (cost=0.00..19.20 rows=920 width=31) (actual time=0.006..0.006 rows=0 loops=1)<br /> -> Append (cost=0.13..172.29 rows=64 width=38) (never executed)<br /> Subplans Removed: 60<br /> -> Index Scan using partitiontable_2024_10_pkey on "PartitionTable_2024_10" t2 (cost=0.43..4.21 rows=1 width=38) (never executed)<br /> Index Cond: (("Col1" = tmp."Col2") AND ("Col3" >= (CURRENT_DATE - '3 mons'::interval)) AND ("Col3" <= CURRENT_DATE))<br /> Filter: ((NOT "IsDeleted") AND ("Col4" = tmp."Col5"))<br /> -> Index Scan using partitiontable_2024_11_pkey on "PartitionTable_2024_11" t3 (cost=0.43..4.23 rows=1 width=38) (never executed)<br /> Index Cond: (("Col1" = tmp."Col2") AND ("Col3" >= (CURRENT_DATE - '3 mons'::interval)) AND ("Col3" <= CURRENT_DATE))<br /> Filter: ((NOT "IsDeleted") AND ("Col4" = tmp."Col5"))<br /> -> Index Scan using partitiontable_2024_12_pkey on "PartitionTable_2024_12" t4 (cost=0.43..4.34 rows=1 width=38) (never executed)<br /> Index Cond: (("Col1" = tmp."Col2") AND ("Col3" >= (CURRENT_DATE - '3 mons'::interval)) AND ("Col3" <= CURRENT_DATE))<br /> Filter: ((NOT "IsDeleted") AND ("Col4" = tmp."Col5"))<br /> -> Index Scan using partitiontable_2025_01_pkey on "PartitionTable_2025_01" t5 (cost=0.43..3.72 rows=1 width=38) (never executed)<br /> Index Cond: (("Col1" = tmp."Col2") AND ("Col3" >= (CURRENT_DATE - '3 mons'::interval)) AND ("Col3" <= CURRENT_DATE))<br /> Filter: ((NOT "IsDeleted") AND ("Col4" = tmp."Col5"))<br /> Planning Time: 3.860 ms<br /> Execution Time: 0.066 ms</blockquote><p><br />Well, it helped, and I missed some bits of information earlier.<br />Generally it looks that it was trying to scan only 4 partitions, but<br />they all got skipped.<br /><br />Best regards,<br /><br />depesz<br /> </p></blockquote><div> </div><div> </div><div>-- </div><div><img src="https://avatars.mds.yandex.net/get-mail-signature/1640102/65bb545ae0f44457010ad3aaa33d1fca/orig" /></div><div> </div>