- Notifications
You must be signed in to change notification settings - Fork4.9k
Commitd4c62a6
committed
Make simplehash.h grow hashtable in additional cases.
Increase the size when either the distance between actual and optimalslot grows too large, or when too many subsequent entries would haveto be moved.This addresses reports that the simplehash performed, sometimesconsiderably, worse than dynahash.The reason turned out to be that insertions into the hashtable where,due to the use of parallel query, in effect done from anotherhashtable, in hash-value order. If the target hashtable, due tomis-estimation, was sized a lot smaller than the source table(s) thatlead to very imbalanced tables; a lot of entries in many close-bybuckets from the source tables were inserted into a single, wider,bucket on the target table. As the growth factor was solely computedbased on the fillfactor, the performance of the table decreasedfurther and further.b81b5a9 was an attempt to address this problem for hashaggregates (but not for bitmap scans), but it turns out that thecurrent method of mixing hash values often actually leaves neighboringhash-values close to each other, just in different value range. Itmight be worth revisiting that independently of the performance issuesaddressed in this patch..To address that problem resize tables in two additional cases: Firstlywhen the optimal position for an entry would be far from the actualposition, secondly when many entries would have to be moved to makespace for the new entry (while satisfying the robin hood property).Due to the additional resizing threshold it seems possible, andtesting confirms that so far, that a higher fillfactor doesn't hurtperformance and saves a bit of memory. It seems better to increase itnow, before a release containing any of this code, rather than wonderin some later release.The various boundaries aren't determined in a particularly scientificmanner, they might need some fine-tuning.In all my tests the new code now, even with parallelism, performs atleast as good as the old code, in several scenarios significantlybetter.Reported-By: Dilip Kumar, Robert Haas, Kuntal GhoshDiscussion:https://postgr.es/m/CAFiTN-vagvuAydKG9VnWcoK=ADAhxmOa4ZTrmNsViBBooTnriQ@mail.gmail.comhttps://postgr.es/m/CAGz5QC+=fNTYgzMLTBUNeKt6uaWZFXJbkB5+7oWm-n9DwVxcLA@mail.gmail.com1 parentff992c0 commitd4c62a6
1 file changed
+50
-5
lines changedLines changed: 50 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
157 | 157 |
| |
158 | 158 |
| |
159 | 159 |
| |
160 |
| - | |
161 |
| - | |
162 |
| - | |
163 |
| - | |
164 | 160 |
| |
165 | 161 |
| |
166 | 162 |
| |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
167 | 178 |
| |
168 | 179 |
| |
169 | 180 |
| |
| |||
466 | 477 |
| |
467 | 478 |
| |
468 | 479 |
| |
469 |
| - | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
470 | 484 |
| |
471 | 485 |
| |
472 | 486 |
| |
473 | 487 |
| |
474 | 488 |
| |
| 489 | + | |
| 490 | + | |
| 491 | + | |
475 | 492 |
| |
476 | 493 |
| |
477 | 494 |
| |
| |||
536 | 553 |
| |
537 | 554 |
| |
538 | 555 |
| |
| 556 | + | |
539 | 557 |
| |
540 | 558 |
| |
541 | 559 |
| |
| |||
550 | 568 |
| |
551 | 569 |
| |
552 | 570 |
| |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
553 | 584 |
| |
554 | 585 |
| |
555 | 586 |
| |
| |||
585 | 616 |
| |
586 | 617 |
| |
587 | 618 |
| |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
588 | 631 |
| |
589 | 632 |
| |
590 | 633 |
| |
| |||
878 | 921 |
| |
879 | 922 |
| |
880 | 923 |
| |
| 924 | + | |
| 925 | + | |
881 | 926 |
| |
882 | 927 |
| |
883 | 928 |
| |
|
0 commit comments
Comments
(0)