Commit 9c3dab9
committed
Introduce the number of columns in the cost-sort model.
The sort node calls the comparison operator for each pair of attributes for
each couple of tuples. However, the current cost model uses
a '2.0*cpu_operator_cost' multiplier, which performs some sort of averaging.
This technique can lead to incorrect estimations when sorting on three, four,
or more columns, quite common in practice.
Moreover, further elaboration of the optimiser forms more strict requirements
for the balance of sortings, as caused by IncrementalSort, MergeAppend, and
MergeJoin.
In this patch, the multiplier is a linear function of a number of columns.
Member 1.0 needs to smooth the fact that dependence on the number of columns is
weaker than linear.
It is an extreme formula. The number of comparisons depends on the distinct
values in each column. As a TODO, we can natively elaborate this model by the
next step, involving distinct statistics to make estimations more precise.
Task: 9578.
Tags: optimized_group_by.1 parent 9ea2614 commit 9c3dab9
File tree
6 files changed
+78
-66
lines changed- contrib/postgres_fdw/expected
- src
- backend/optimizer/path
- test/regress/expected
6 files changed
+78
-66
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9984 | 9984 | | |
9985 | 9985 | | |
9986 | 9986 | | |
9987 | | - | |
9988 | | - | |
9989 | | - | |
| 9987 | + | |
| 9988 | + | |
| 9989 | + | |
9990 | 9990 | | |
9991 | | - | |
9992 | | - | |
9993 | | - | |
| 9991 | + | |
| 9992 | + | |
| 9993 | + | |
| 9994 | + | |
| 9995 | + | |
| 9996 | + | |
9994 | 9997 | | |
9995 | 9998 | | |
9996 | 9999 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
483 | 483 | | |
484 | 484 | | |
485 | 485 | | |
| 486 | + | |
| 487 | + | |
486 | 488 | | |
487 | 489 | | |
488 | 490 | | |
| |||
505 | 507 | | |
506 | 508 | | |
507 | 509 | | |
508 | | - | |
| 510 | + | |
509 | 511 | | |
510 | 512 | | |
511 | 513 | | |
| |||
1863 | 1865 | | |
1864 | 1866 | | |
1865 | 1867 | | |
1866 | | - | |
| 1868 | + | |
1867 | 1869 | | |
1868 | 1870 | | |
1869 | 1871 | | |
| |||
1880 | 1882 | | |
1881 | 1883 | | |
1882 | 1884 | | |
1883 | | - | |
| 1885 | + | |
1884 | 1886 | | |
1885 | 1887 | | |
1886 | 1888 | | |
| |||
2051 | 2053 | | |
2052 | 2054 | | |
2053 | 2055 | | |
2054 | | - | |
| 2056 | + | |
| 2057 | + | |
| 2058 | + | |
2055 | 2059 | | |
2056 | 2060 | | |
2057 | 2061 | | |
| |||
2075 | 2079 | | |
2076 | 2080 | | |
2077 | 2081 | | |
2078 | | - | |
| 2082 | + | |
2079 | 2083 | | |
2080 | 2084 | | |
2081 | 2085 | | |
| |||
2109 | 2113 | | |
2110 | 2114 | | |
2111 | 2115 | | |
| 2116 | + | |
| 2117 | + | |
2112 | 2118 | | |
2113 | 2119 | | |
2114 | | - | |
| 2120 | + | |
2115 | 2121 | | |
2116 | 2122 | | |
2117 | 2123 | | |
| |||
2391 | 2397 | | |
2392 | 2398 | | |
2393 | 2399 | | |
| 2400 | + | |
| 2401 | + | |
2394 | 2402 | | |
2395 | 2403 | | |
2396 | 2404 | | |
| |||
2399 | 2407 | | |
2400 | 2408 | | |
2401 | 2409 | | |
2402 | | - | |
| 2410 | + | |
2403 | 2411 | | |
2404 | 2412 | | |
2405 | 2413 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3001 | 3001 | | |
3002 | 3002 | | |
3003 | 3003 | | |
3004 | | - | |
3005 | | - | |
| 3004 | + | |
| 3005 | + | |
3006 | 3006 | | |
3007 | 3007 | | |
3008 | 3008 | | |
3009 | 3009 | | |
3010 | | - | |
| 3010 | + | |
3011 | 3011 | | |
3012 | | - | |
3013 | | - | |
3014 | | - | |
| 3012 | + | |
| 3013 | + | |
| 3014 | + | |
| 3015 | + | |
3015 | 3016 | | |
3016 | 3017 | | |
3017 | 3018 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5726 | 5726 | | |
5727 | 5727 | | |
5728 | 5728 | | |
5729 | | - | |
5730 | | - | |
5731 | | - | |
5732 | | - | |
5733 | | - | |
5734 | | - | |
5735 | | - | |
5736 | | - | |
| 5729 | + | |
| 5730 | + | |
| 5731 | + | |
| 5732 | + | |
5737 | 5733 | | |
5738 | 5734 | | |
5739 | 5735 | | |
5740 | | - | |
| 5736 | + | |
| 5737 | + | |
| 5738 | + | |
| 5739 | + | |
| 5740 | + | |
| 5741 | + | |
| 5742 | + | |
5741 | 5743 | | |
5742 | 5744 | | |
5743 | 5745 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1235 | 1235 | | |
1236 | 1236 | | |
1237 | 1237 | | |
1238 | | - | |
| 1238 | + | |
1239 | 1239 | | |
1240 | | - | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
1241 | 1243 | | |
1242 | 1244 | | |
1243 | 1245 | | |
| |||
1286 | 1288 | | |
1287 | 1289 | | |
1288 | 1290 | | |
1289 | | - | |
| 1291 | + | |
1290 | 1292 | | |
1291 | 1293 | | |
1292 | 1294 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1224 | 1224 | | |
1225 | 1225 | | |
1226 | 1226 | | |
1227 | | - | |
1228 | | - | |
| 1227 | + | |
| 1228 | + | |
1229 | 1229 | | |
1230 | 1230 | | |
1231 | | - | |
1232 | | - | |
1233 | | - | |
1234 | | - | |
1235 | | - | |
1236 | | - | |
1237 | | - | |
1238 | | - | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
1239 | 1238 | | |
1240 | 1239 | | |
1241 | 1240 | | |
| |||
1289 | 1288 | | |
1290 | 1289 | | |
1291 | 1290 | | |
1292 | | - | |
1293 | | - | |
| 1291 | + | |
| 1292 | + | |
1294 | 1293 | | |
1295 | 1294 | | |
1296 | 1295 | | |
1297 | 1296 | | |
1298 | | - | |
1299 | | - | |
1300 | | - | |
1301 | | - | |
1302 | | - | |
1303 | | - | |
1304 | | - | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
1305 | 1303 | | |
1306 | 1304 | | |
1307 | 1305 | | |
| |||
1322 | 1320 | | |
1323 | 1321 | | |
1324 | 1322 | | |
1325 | | - | |
1326 | | - | |
1327 | | - | |
1328 | | - | |
1329 | | - | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
1330 | 1328 | | |
1331 | | - | |
1332 | | - | |
1333 | | - | |
1334 | | - | |
1335 | | - | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
1336 | 1333 | | |
1337 | | - | |
1338 | | - | |
1339 | | - | |
1340 | | - | |
1341 | | - | |
1342 | | - | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
1343 | 1339 | | |
1344 | 1340 | | |
1345 | 1341 | | |
| |||
0 commit comments