Use an index scan in RemoveSubscriptionRel() when possible. Previously, RemoveSubscriptionRel() scanned all of pg_subscription_rel with a heap scan, even when given a relation OID that the (srrelid, srsubid) primary key index could serve. Since it's called for every dropped relation, dropping tables on a subscriber with a large pg_subscription_rel could be slow.
Use the index when a relation OID is given. DROP SUBSCRIPTION passes only a subscription OID (the second index column), so it keeps using a heap scan. In a performance test with 100,000 entries in pg_subscription_rel, dropping 1,000 tables became 10x faster. Author: Manu <[email protected]> Reviewed-by: Chao Li <[email protected]> Reviewed-by: Masahiko Sawada <[email protected]> Discussion: https://postgr.es/m/[email protected] Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/72146c7db15773ba0660c7c7e0284e3b1116ae2f Modified Files -------------- src/backend/catalog/pg_subscription.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-)
