Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: postgresql-cfbot/postgresql
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: cf/3701~1
Choose a base ref
...
head repository: postgresql-cfbot/postgresql
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: cf/3701
Choose a head ref
  • 2 commits
  • 9 files changed
  • 3 contributors

Commits on Apr 8, 2025

  1. Speedup child EquivalenceMember lookup in planner

    When planning queries to partitioned tables, we create child
    EquivalenceMembers for each EquivalenceMembers which mentions the parent
    partitioned table.  For partitioned tables with large numbers of
    partitions, this meant we could end up with many EquivalenceMembers and
    this could cause the planner to become slow due to the linear lookups
    that are performed on the EquivalenceClass ec_members's List.
    Effectively, the more partitions which were present, the more lookups
    needed to be performed for operations such as
    find_ec_member_matching_expr() during create_plan() and the more
    partitions present, the longer these searches would take.
    
    To fix this, here we adjust how we store EquivalenceMembers for
    em_is_child members.  Instead of storing these directly in ec_members,
    these are now stored in a new array of Lists in the EquivalenceClass
    which is indexed by the relid.  When we want to find EquivalenceMembers
    belonging to a certain child relation, we can narrow the search to the
    array element for that relation.
    
    To make EquivalenceMember lookup easier and to reduce the amount of code
    change, this commit provides a pair of functions to allow iteration over
    the EquivalenceMembers in a class which handles finding the child
    members, if required.  Callers that never need to look at child members
    can remain using the foreach loop over ec_members, which will now often
    be faster due to only parent-level members being stored there.
    
    The actual performance increases here are highly dependent on the number
    of partitions and the query being planned.  Performance increase can be
    visible with as few as 8 partitions, but the speedup is marginal for
    such low numbers of partitions.  The speedups become much more visible
    with a few dozen to hundreds of partitions.  Some tested queries were
    around 3x faster with 256 partitions.  For users with thousands of
    partitions, these are likely to become significantly faster.  Some
    testing has shown planner speedups of 20x or more.
    
    Author: Yuya Watari <[email protected]>
    Co-authored-by: David Rowley <[email protected]>
    Reviewed-by: David Rowley <[email protected]>
    Reviewed-by: Tom Lane <[email protected]>
    Reviewed-by: Andrey Lepikhov <[email protected]>
    Reviewed-by: Alena Rybakina <[email protected]>
    Reviewed-by: Dmitry Dolgov <[email protected]>
    Reviewed-by: Amit Langote <[email protected]>
    Tested-by: Thom Brown <[email protected]>
    Tested-by: Ashutosh Bapat <[email protected]>
    Tested-by: newtglobal postgresql_contributors <[email protected]>
    Discussion: https://postgr.es/m/CAJ2pMkZNCgoUKSE%2B_5LthD%2BKbXKvq6h2hQN8Esxpxd%2Bcxmgomg%40mail.gmail.com
    2 people authored and Commitfest Bot committed Apr 8, 2025
    Configuration menu
    Copy the full SHA
    1d7f52c View commit details
    Browse the repository at this point in the history
  2. [CF 3701] v42 - Reducing planning time when tables have many partitions

    This branch was automatically generated by a robot using patches from an
    email thread registered at:
    
    https://commitfest.postgresql.org/patch/3701
    
    The branch will be overwritten each time a new patch version is posted to
    the thread, and also periodically to check for bitrot caused by changes
    on the master branch.
    
    Patch(es): https://www.postgresql.org/message-id/CAApHDvpf+2rUi3rOepS9jMjiS3ezH9VcZisS+A+Ob5G5YpBZxg@mail.gmail.com
    Author(s): Yuya Watari
    Commitfest Bot committed Apr 8, 2025
    Configuration menu
    Copy the full SHA
    38e936a View commit details
    Browse the repository at this point in the history
Loading