forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitefc77cf
committed
Fix intarray's GiST opclasses to not fail for empty arrays with <@.
contrib/intarray considers "arraycol <@ constant-array" to be indexable,but its GiST opclass code fails to reliably find index entries for emptyarray values (which of course should trivially match such queries).This is because the test condition to see whether we should descendthrough a non-leaf node is wrong.Unfortunately, empty array entries could be anywhere in the index,as these index opclasses are currently designed. So there's no wayto fix this except by lobotomizing <@ indexscans to scan the wholeindex ... which is what this patch does. That's pretty unfortunate:the performance is now actually worse than a seqscan, in most cases.We'd be better off to remove <@ from the GiST opclasses entirely,and perhaps a future non-back-patchable patch will do so.In the meantime, applications whose performance is adversely impactedhave a couple of options. They could switch to a GIN index, whichdoesn't have this bug, or they could replace "arraycol <@ constant-array"with "arraycol <@ constant-array AND arraycol && constant-array".That will provide about the same performance as before, and it will findall non-empty subsets of the given constant-array, which is all thatcould reliably be expected of the query before.While at it, add some more regression test cases to improve codecoverage of contrib/intarray.In passing, adjust resize_intArrayType so that when it's returning anempty array, it uses construct_empty_array for that rather thancowboy hacking on the input array. While the hack produces an arraythat looks valid for most purposes, it isn't bitwise equal to emptyarrays produced by other code paths, which could have subtle oddeffects. I don't think this code path is performance-criticalenough to justify such shortcuts. (Back-patch this part only as faras v11; before commit01783ac we were not careful about this inother intarray code paths either.)Back-patch the <@ fixes to all supported versions, since this wasbroken from day one.Patch by me; thanks to Alexander Korotkov for review.Discussion:https://postgr.es/m/458.1565114141@sss.pgh.pa.us1 parent4ecd05c commitefc77cf
File tree
5 files changed
+133
-4
lines changed- contrib/intarray
- expected
- sql
5 files changed
+133
-4
lines changedLines changed: 7 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
96 | 96 |
| |
97 | 97 |
| |
98 | 98 |
| |
99 |
| - | |
100 |
| - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
101 | 106 |
| |
102 | 107 |
| |
103 | 108 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
256 | 256 |
| |
257 | 257 |
| |
258 | 258 |
| |
259 |
| - | |
| 259 | + | |
260 | 260 |
| |
261 | 261 |
| |
262 | 262 |
| |
|
Lines changed: 7 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
567 | 567 |
| |
568 | 568 |
| |
569 | 569 |
| |
570 |
| - | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
571 | 577 |
| |
572 | 578 |
| |
573 | 579 |
| |
|
Lines changed: 98 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
431 | 431 |
| |
432 | 432 |
| |
433 | 433 |
| |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
434 | 446 |
| |
435 | 447 |
| |
436 | 448 |
| |
| |||
449 | 461 |
| |
450 | 462 |
| |
451 | 463 |
| |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
452 | 477 |
| |
453 | 478 |
| |
454 | 479 |
| |
| |||
480 | 505 |
| |
481 | 506 |
| |
482 | 507 |
| |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
483 | 520 |
| |
484 | 521 |
| |
485 | 522 |
| |
| |||
498 | 535 |
| |
499 | 536 |
| |
500 | 537 |
| |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
501 | 550 |
| |
502 | 551 |
| |
503 | 552 |
| |
| |||
530 | 579 |
| |
531 | 580 |
| |
532 | 581 |
| |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
533 | 594 |
| |
534 | 595 |
| |
535 | 596 |
| |
| |||
548 | 609 |
| |
549 | 610 |
| |
550 | 611 |
| |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
551 | 624 |
| |
552 | 625 |
| |
553 | 626 |
| |
| |||
580 | 653 |
| |
581 | 654 |
| |
582 | 655 |
| |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
583 | 668 |
| |
584 | 669 |
| |
585 | 670 |
| |
| |||
598 | 683 |
| |
599 | 684 |
| |
600 | 685 |
| |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + |
Lines changed: 20 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
85 | 85 |
| |
86 | 86 |
| |
87 | 87 |
| |
| 88 | + | |
| 89 | + | |
88 | 90 |
| |
89 | 91 |
| |
90 | 92 |
| |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
91 | 97 |
| |
92 | 98 |
| |
93 | 99 |
| |
| |||
96 | 102 |
| |
97 | 103 |
| |
98 | 104 |
| |
| 105 | + | |
| 106 | + | |
99 | 107 |
| |
100 | 108 |
| |
101 | 109 |
| |
| 110 | + | |
| 111 | + | |
102 | 112 |
| |
103 | 113 |
| |
104 | 114 |
| |
| |||
108 | 118 |
| |
109 | 119 |
| |
110 | 120 |
| |
| 121 | + | |
| 122 | + | |
111 | 123 |
| |
112 | 124 |
| |
113 | 125 |
| |
| 126 | + | |
| 127 | + | |
114 | 128 |
| |
115 | 129 |
| |
116 | 130 |
| |
| |||
120 | 134 |
| |
121 | 135 |
| |
122 | 136 |
| |
| 137 | + | |
| 138 | + | |
123 | 139 |
| |
124 | 140 |
| |
125 | 141 |
| |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + |
0 commit comments
Comments
(0)