forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commiteae056c
committed
Apply multiple multivariate MCV lists when possible
Until now we've only used a single multivariate MCV list per relation,covering the largest number of clauses. So for example given a query SELECT * FROM t WHERE a = 1 AND b =1 AND c = 1 AND d = 1and extended statistics on (a,b) and (c,d), we'd only pick and use oneof them. This commit improves this by repeatedly picking and applyingthe best statistics (matching the largest number of remaining clauses)until no additional statistics is applicable.This greedy algorithm is simple, but may not be optimal. A differentchoice of statistics may leave fewer clauses unestimated and/or givebetter estimates for some other reason.This can however happen only when there are overlapping statistics, andselecting one makes it impossible to use the other. E.g. with statisticson (a,b), (c,d), (b,c,d), we may pick either (a,b) and (c,d) or (b,c,d).But it's not clear which option is the best one.We however assume cases like this are rare, and the easiest solution isto define statistics covering the whole group of correlated columns. Inthe future we might support overlapping stats, using some of the clausesas conditions (in conditional probability sense).Author: Tomas VondraReviewed-by: Mark Dilger, Kyotaro HoriguchiDiscussion:https://postgr.es/m/20191028152048.jc6pqv5hb7j77ocp@development1 parentaaa6761 commiteae056c
File tree
3 files changed
+167
-64
lines changed- src
- backend/statistics
- test/regress
- expected
- sql
3 files changed
+167
-64
lines changedLines changed: 75 additions & 64 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1148 | 1148 |
| |
1149 | 1149 |
| |
1150 | 1150 |
| |
1151 |
| - | |
1152 |
| - | |
1153 |
| - | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
1154 | 1158 |
| |
1155 | 1159 |
| |
1156 | 1160 |
| |
| |||
1194 | 1198 |
| |
1195 | 1199 |
| |
1196 | 1200 |
| |
1197 |
| - | |
1198 |
| - | |
1199 |
| - | |
1200 |
| - | |
1201 |
| - | |
1202 | 1201 |
| |
1203 | 1202 |
| |
1204 | 1203 |
| |
| |||
1208 | 1207 |
| |
1209 | 1208 |
| |
1210 | 1209 |
| |
1211 |
| - | |
1212 |
| - | |
1213 |
| - | |
1214 |
| - | |
1215 |
| - | |
1216 |
| - | |
1217 |
| - | |
1218 |
| - | |
| 1210 | + | |
1219 | 1211 |
| |
1220 | 1212 |
| |
1221 | 1213 |
| |
| |||
1250 | 1242 |
| |
1251 | 1243 |
| |
1252 | 1244 |
| |
1253 |
| - | |
1254 |
| - | |
1255 |
| - | |
1256 |
| - | |
1257 |
| - | |
1258 |
| - | |
1259 |
| - | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
1260 | 1264 |
| |
1261 |
| - | |
1262 |
| - | |
| 1265 | + | |
| 1266 | + | |
1263 | 1267 |
| |
1264 |
| - | |
1265 |
| - | |
| 1268 | + | |
| 1269 | + | |
1266 | 1270 |
| |
1267 |
| - | |
1268 |
| - | |
1269 |
| - | |
1270 |
| - | |
1271 |
| - | |
1272 |
| - | |
1273 |
| - | |
1274 |
| - | |
1275 |
| - | |
| 1271 | + | |
| 1272 | + | |
1276 | 1273 |
| |
1277 |
| - | |
1278 |
| - | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
1279 | 1289 |
| |
1280 | 1290 |
| |
1281 |
| - | |
1282 |
| - | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
1283 | 1299 |
| |
1284 |
| - | |
1285 |
| - | |
1286 |
| - | |
1287 |
| - | |
1288 |
| - | |
1289 |
| - | |
1290 |
| - | |
1291 |
| - | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
1292 | 1307 |
| |
1293 |
| - | |
1294 |
| - | |
1295 |
| - | |
1296 |
| - | |
1297 |
| - | |
1298 |
| - | |
1299 |
| - | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
1300 | 1311 |
| |
1301 |
| - | |
1302 |
| - | |
1303 |
| - | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
1304 | 1315 |
| |
1305 |
| - | |
1306 |
| - | |
1307 |
| - | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
1308 | 1319 |
| |
1309 |
| - | |
1310 |
| - | |
1311 |
| - | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
1312 | 1323 |
| |
1313 | 1324 |
| |
1314 | 1325 |
| |
|
Lines changed: 57 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
836 | 836 |
| |
837 | 837 |
| |
838 | 838 |
| |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
839 | 896 |
| |
840 | 897 |
| |
841 | 898 |
| |
|
Lines changed: 35 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
535 | 535 |
| |
536 | 536 |
| |
537 | 537 |
| |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
538 | 573 |
| |
539 | 574 |
| |
540 | 575 |
| |
|
0 commit comments
Comments
(0)