- Notifications
You must be signed in to change notification settings - Fork5
Commit31f38f2
committed
Redesign the planner's handling of index-descent cost estimation.
Historically we've used a couple of very ad-hoc fudge factors to try toget the right results when indexes of different sizes would satisfy aquery with the same number of index leaf tuples being visited. Incommit21a39de I tweaked one of thesefudge factors, with results that proved disastrous for larger indexes.Commitbf01e34 fudged it some more,but still with not a lot of principle behind it.What seems like a better way to address these issues is to explicitly modelindex-descent costs, since that's what's really at stake when consideringdiferent indexes with similar leaf-page-level costs. We tried that oncelong ago, and found that charging random_page_cost per page descendedthrough was way too much, because upper btree levels tend to stay in cachein real-world workloads. However, there's still CPU costs to think about,and the previous fudge factors can be seen as a crude attempt to accountfor those costs. So this patch replaces those fudge factors with explicitcharges for the number of tuple comparisons needed to descend the indextree, plus a small charge per page touched in the descent. The costmultipliers are chosen so that the resulting charges are in the vicinity ofthe historical (pre-9.2) fudge factors for indexes of up to about a milliontuples, while not ballooning unreasonably beyond that, as the old fudgefactor did (even more so in 9.2).To make this work accurately for btree indexes, add some code that allowsextraction of the known root-page height from a btree. There's noequivalent number readily available for other index types, but we can usethe log of the number of index pages as an approximate substitute.This seems like too much of a behavioral change to risk back-patching,but it should improve matters going forward. In 9.2 I'll just revertthe fudge-factor change.1 parente1b735a commit31f38f2
File tree
6 files changed
+372
-118
lines changed- src
- backend
- access/nbtree
- nodes
- optimizer/util
- utils/adt
- include
- access
- nodes
6 files changed
+372
-118
lines changedLines changed: 76 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
411 | 411 |
| |
412 | 412 |
| |
413 | 413 |
| |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
414 | 490 |
| |
415 | 491 |
| |
416 | 492 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1772 | 1772 |
| |
1773 | 1773 |
| |
1774 | 1774 |
| |
| 1775 | + | |
1775 | 1776 |
| |
| 1777 | + | |
1776 | 1778 |
| |
1777 | 1779 |
| |
1778 | 1780 |
| |
| |||
1781 | 1783 |
| |
1782 | 1784 |
| |
1783 | 1785 |
| |
| 1786 | + | |
1784 | 1787 |
| |
1785 | 1788 |
| |
1786 | 1789 |
| |
|
Lines changed: 12 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
20 | 20 |
| |
21 | 21 |
| |
22 | 22 |
| |
| 23 | + | |
23 | 24 |
| |
24 | 25 |
| |
25 | 26 |
| |
| |||
352 | 353 |
| |
353 | 354 |
| |
354 | 355 |
| |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
355 | 367 |
| |
356 | 368 |
| |
357 | 369 |
| |
|
0 commit comments
Comments
(0)