Re: [PATCH] Use indexes on the subscriber when REPLICA IDENTITY is full on the publisher
Amit Kapila <amit.kapila16@gmail.com>
From: Amit Kapila <amit.kapila16@gmail.com>
To: Önder Kalacı <onderkalaci@gmail.com>
Cc: "shiy.fnst@fujitsu.com" <shiy.fnst@fujitsu.com>,
Andres Freund <andres@anarazel.de>, Marco Slot <marco.slot@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>, "wangw.fnst@fujitsu.com" <wangw.fnst@fujitsu.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2023-03-03T02:46:10Z
Lists: pgsql-hackers
On Thu, Mar 2, 2023 at 6:50 PM Önder Kalacı <onderkalaci@gmail.com> wrote: > >> >> >> In the above profile number of calls to index_fetch_heap(), >> heapam_index_fetch_tuple() explains the reason for the regression you >> are seeing with the index scan. Because the update will generate dead >> tuples in the same transaction and those dead tuples won't be removed, >> we get those from the index and then need to perform >> index_fetch_heap() to find out whether the tuple is dead or not. Now, >> for sequence scan also we need to scan those dead tuples but there we >> don't need to do back-and-forth between index and heap. > > > Thanks for the insights, I think what you describe makes a lot of sense. > ... ... > > I think we figured out the cause of the performance regression. I think it is not small > enough for some scenarios like the above. But those scenarios seem like synthetic > test cases, with not much user impacting implications. Still, I think you are better suited > to comment on this. > > If you consider that this is a significant issue, we could consider the second patch as well > such that for this unlikely scenario users could disable index scans. > I think we can't completely ignore this regression because the key point of this patch is to pick one of the non-unique indexes to perform scan and now it will be difficult to predict how many duplicates (and or dead rows) some index has without more planner support. Personally, I feel it is better to have a table-level option for this so that users have some knob to avoid regressions in particular cases. In general, I agree that it will be a win in more number of cases than it can regress. -- With Regards, Amit Kapila.
Commits
-
Add the testcases for 89e46da5e5.
- 805b821e77a3 16.0 landed
-
Allow the use of indexes other than PK and REPLICA IDENTITY on the subscriber.
- 89e46da5e511 16.0 landed
-
Rework query relation permission checking
- a61b1f74823c 16.0 cited
-
Generalize ri_RootToPartitionMap to use for non-partition children
- fb958b5da86d 16.0 cited
-
Add wait_for_subscription_sync for TAP tests.
- 0c20dd33db16 16.0 cited
-
Logical replication
- 665d1fad99e7 10.0 cited