forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit499be01
committed
Support partition pruning at execution time
Existing partition pruning is only able to work at plan time, for queryquals that appear in the parsed query. This is good but limiting, asthere can be parameters that appear later that can be usefully used tofurther prune partitions.This commit adds support for pruning subnodes of Append which cannotpossibly contain any matching tuples, during execution, by evaluatingParams to determine the minimum set of subnodes that can possibly match.We support more than just simple Params in WHERE clauses. Supportadditionally includes:1. Parameterized Nested Loop Joins: The parameter from the outer side of the join can be used to determine the minimum set of inner side partitions to scan.2. Initplans: Once an initplan has been executed we can then determine which partitions match the value from the initplan.Partition pruning is performed in two ways. When Params external to the planare found to match the partition key we attempt to prune away unneeded Appendsubplans during the initialization of the executor. This allows us to bypassthe initialization of non-matching subplans meaning they won't appear in theEXPLAIN or EXPLAIN ANALYZE output.For parameters whose value is only known during the actual executionthen the pruning of these subplans must wait. Subplans which areeliminated during this stage of pruning are still visible in the EXPLAINoutput. In order to determine if pruning has actually taken place, theEXPLAIN ANALYZE must be viewed. If a certain Append subplan was neverexecuted due to the elimination of the partition then the executiontiming area will state "(never executed)". Whereas, if, for example inthe case of parameterized nested loops, the number of loops stated inthe EXPLAIN ANALYZE output for certain subplans may appear lower thanothers due to the subplan having been scanned fewer times. This is dueto the list of matching subnodes having to be evaluated whenever aparameter which was found to match the partition key changes.This commit required some additional infrastructure that permits thebuilding of a data structure which is able to perform the translation ofthe matching partition IDs, as returned by get_matching_partitions, intothe list index of a subpaths list, as exist in node types such asAppend, MergeAppend and ModifyTable. This allows us to translate a listof clauses into a Bitmapset of all the subpath indexes which must beincluded to satisfy the clause list.Author: David Rowley, based on an earlier effort by Beena EmersonReviewers: Amit Langote, Robert Haas, Amul Sul, Rajkumar Raghuwanshi,Jesper PedersenDiscussion:https://postgr.es/m/CAOG9ApE16ac-_VVZVvv0gePSgkg_BwYEV1NBqZFqDR2bBE0X0A@mail.gmail.com1 parent5c06752 commit499be01
File tree
24 files changed
+2714
-112
lines changed- doc/src/sgml
- src
- backend
- commands
- executor
- nodes
- optimizer
- path
- plan
- prep
- util
- partitioning
- include
- executor
- nodes
- optimizer
- partitioning
- test/regress
- expected
- sql
24 files changed
+2714
-112
lines changedLines changed: 12 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
894 | 894 |
| |
895 | 895 |
| |
896 | 896 |
| |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
897 | 909 |
| |
898 | 910 |
| |
899 | 911 |
| |
|
Lines changed: 33 additions & 18 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
118 | 118 |
| |
119 | 119 |
| |
120 | 120 |
| |
121 |
| - | |
122 |
| - | |
| 121 | + | |
| 122 | + | |
123 | 123 |
| |
124 | 124 |
| |
125 | 125 |
| |
| |||
1811 | 1811 |
| |
1812 | 1812 |
| |
1813 | 1813 |
| |
1814 |
| - | |
1815 |
| - | |
| 1814 | + | |
| 1815 | + | |
| 1816 | + | |
1816 | 1817 |
| |
1817 | 1818 |
| |
1818 | 1819 |
| |
1819 |
| - | |
1820 |
| - | |
| 1820 | + | |
| 1821 | + | |
| 1822 | + | |
1821 | 1823 |
| |
1822 | 1824 |
| |
1823 | 1825 |
| |
1824 |
| - | |
1825 |
| - | |
| 1826 | + | |
| 1827 | + | |
| 1828 | + | |
1826 | 1829 |
| |
1827 | 1830 |
| |
1828 | 1831 |
| |
1829 |
| - | |
1830 |
| - | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
1831 | 1835 |
| |
1832 | 1836 |
| |
1833 | 1837 |
| |
1834 |
| - | |
1835 |
| - | |
| 1838 | + | |
| 1839 | + | |
| 1840 | + | |
1836 | 1841 |
| |
1837 | 1842 |
| |
1838 | 1843 |
| |
| |||
3173 | 3178 |
| |
3174 | 3179 |
| |
3175 | 3180 |
| |
3176 |
| - | |
3177 |
| - | |
3178 |
| - | |
| 3181 | + | |
| 3182 | + | |
| 3183 | + | |
| 3184 | + | |
3179 | 3185 |
| |
3180 | 3186 |
| |
3181 |
| - | |
| 3187 | + | |
3182 | 3188 |
| |
3183 | 3189 |
| |
3184 |
| - | |
3185 | 3190 |
| |
3186 | 3191 |
| |
3187 |
| - | |
| 3192 | + | |
| 3193 | + | |
| 3194 | + | |
| 3195 | + | |
| 3196 | + | |
| 3197 | + | |
| 3198 | + | |
| 3199 | + | |
| 3200 | + | |
| 3201 | + | |
| 3202 | + | |
3188 | 3203 |
| |
3189 | 3204 |
| |
3190 | 3205 |
| |
|
0 commit comments
Comments
(0)