aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeModifyTable.c
diff options
context:
space:
mode:
authorTomas Vondra <tomas.vondra@postgresql.org>2019-07-04 23:02:02 +0200
committerTomas Vondra <tomas.vondra@postgresql.org>2019-07-05 01:32:33 +0200
commite365a581c246a8e18f38cc530013391329dcdb02 (patch)
treee7e4375ab9fdcae188a756318a6d72e9075e3517 /src/backend/executor/nodeModifyTable.c
parentd5ab9df7774b4570ff50e64b7fa3ba8295596d06 (diff)
downloadpostgresql-e365a581c246a8e18f38cc530013391329dcdb02.tar.gz
postgresql-e365a581c246a8e18f38cc530013391329dcdb02.zip
Speed-up build of MCV lists with many distinct values
When building multi-column MCV lists, we compute base frequency for each item, i.e. a product of per-column frequencies for values from the item. As a value may be in multiple groups, the code was scanning the whole array of groups while adding items to the MCV list. This works fine as long as the number of distinct groups is small, but it's easy to trigger trigger O(N^2) behavior, especially after increasing statistics target. This commit precomputes frequencies for values in all columns, so that when computing the base frequency it's enough to make a simple bsearch lookup in the array. Backpatch to 12, where multi-column MCV lists were introduced. Discussion: https://postgr.es/m/20190618205920.qtlzcu73whfpfqne@development
Diffstat (limited to 'src/backend/executor/nodeModifyTable.c')
0 files changed, 0 insertions, 0 deletions