forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit29b64d1
committed
Add nbtree high key "continuescan" optimization.
Teach nbtree forward index scans to check the high key before moving tothe right sibling page in the hope of finding that it isn't actuallynecessary to do so. The new check may indicate that the scan definitelycannot find matching tuples to the right, ending the scan immediately.We already opportunistically force a similar "continuescan orientated"key check of the final non-pivot tuple when it's clear that it cannot bereturned to the scan due to being dead-to-all. The new high key checkis complementary.The new approach for forward scans is more effective than checking thefinal non-pivot tuple, especially with composite indexes and non-uniqueindexes. The improvements to the logic for picking a split point addedby commitfab2502 make it likely that relatively dissimilar high keyswill appear on a page. A distinguishing key value that can only appearon non-pivot tuples on the right sibling page will often be present inleaf page high keys.Since forcing the final item to be key checked no longer makes anydifference in the case of forward scans, the existing extra key check isnow only used for backwards scans. Backward scans continue toopportunistically check the final non-pivot tuple, which is actually thefirst non-pivot tuple on the page (not the last).Note that even pg_upgrade'd v3 indexes make use of this optimization.Author: Peter Geoghegan, Heikki LinnakangasReviewed-By: Heikki LinnakangasDiscussion:https://postgr.es/m/CAH2-WzkOmUduME31QnuTFpimejuQoiZ-HOf0pOWeFZNhTMctvA@mail.gmail.com1 parent4ba96d1 commit29b64d1
File tree
3 files changed
+128
-77
lines changed- src
- backend/access/nbtree
- include/access
3 files changed
+128
-77
lines changedLines changed: 78 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1406 | 1406 |
| |
1407 | 1407 |
| |
1408 | 1408 |
| |
1409 |
| - | |
1410 | 1409 |
| |
| 1410 | + | |
1411 | 1411 |
| |
1412 | 1412 |
| |
1413 | 1413 |
| |
| |||
1427 | 1427 |
| |
1428 | 1428 |
| |
1429 | 1429 |
| |
| 1430 | + | |
| 1431 | + | |
1430 | 1432 |
| |
1431 | 1433 |
| |
1432 | 1434 |
| |
| |||
1468 | 1470 |
| |
1469 | 1471 |
| |
1470 | 1472 |
| |
1471 |
| - | |
1472 |
| - | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
1473 | 1489 |
| |
1474 | 1490 |
| |
1475 | 1491 |
| |
1476 | 1492 |
| |
1477 | 1493 |
| |
| 1494 | + | |
1478 | 1495 |
| |
1479 |
| - | |
1480 |
| - | |
1481 |
| - | |
1482 | 1496 |
| |
1483 |
| - | |
1484 | 1497 |
| |
1485 | 1498 |
| |
1486 | 1499 |
| |
1487 | 1500 |
| |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
1488 | 1525 |
| |
1489 | 1526 |
| |
1490 | 1527 |
| |
| |||
1499 | 1536 |
| |
1500 | 1537 |
| |
1501 | 1538 |
| |
1502 |
| - | |
1503 |
| - | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
1504 | 1573 |
| |
1505 | 1574 |
| |
1506 | 1575 |
| |
|
Lines changed: 48 additions & 65 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
48 | 48 |
| |
49 | 49 |
| |
50 | 50 |
| |
51 |
| - | |
| 51 | + | |
52 | 52 |
| |
53 | 53 |
| |
54 | 54 |
| |
| |||
1333 | 1333 |
| |
1334 | 1334 |
| |
1335 | 1335 |
| |
1336 |
| - | |
1337 |
| - | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
1338 | 1340 |
| |
1339 |
| - | |
1340 |
| - | |
1341 |
| - | |
1342 |
| - | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
1343 | 1344 |
| |
1344 | 1345 |
| |
1345 |
| - | |
1346 |
| - | |
| 1346 | + | |
| 1347 | + | |
1347 | 1348 |
| |
1348 | 1349 |
| |
1349 |
| - | |
1350 |
| - | |
1351 | 1350 |
| |
1352 |
| - | |
1353 |
| - | |
1354 |
| - | |
| 1351 | + | |
| 1352 | + | |
1355 | 1353 |
| |
1356 | 1354 |
| |
1357 |
| - | |
1358 |
| - | |
1359 |
| - | |
1360 | 1355 |
| |
1361 | 1356 |
| |
1362 | 1357 |
| |
1363 | 1358 |
| |
1364 | 1359 |
| |
1365 | 1360 |
| |
1366 |
| - | |
1367 |
| - | |
1368 |
| - | |
1369 |
| - | |
1370 |
| - | |
1371 |
| - | |
1372 |
| - | |
1373 |
| - | |
1374 |
| - | |
1375 |
| - | |
1376 |
| - | |
1377 |
| - | |
1378 |
| - | |
1379 |
| - | |
1380 |
| - | |
1381 |
| - | |
1382 |
| - | |
1383 |
| - | |
1384 |
| - | |
1385 |
| - | |
1386 |
| - | |
1387 |
| - | |
1388 |
| - | |
1389 |
| - | |
1390 |
| - | |
1391 |
| - | |
1392 |
| - | |
1393 |
| - | |
1394 |
| - | |
1395 |
| - | |
1396 |
| - | |
1397 |
| - | |
1398 |
| - | |
1399 |
| - | |
| 1361 | + | |
1400 | 1362 |
| |
1401 |
| - | |
| 1363 | + | |
1402 | 1364 |
| |
1403 | 1365 |
| |
1404 | 1366 |
| |
| |||
1410 | 1372 |
| |
1411 | 1373 |
| |
1412 | 1374 |
| |
1413 |
| - | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
1414 | 1387 |
| |
1415 | 1388 |
| |
1416 | 1389 |
| |
1417 |
| - | |
| 1390 | + | |
| 1391 | + | |
1418 | 1392 |
| |
1419 |
| - | |
| 1393 | + | |
1420 | 1394 |
| |
1421 | 1395 |
| |
1422 | 1396 |
| |
| |||
1454 | 1428 |
| |
1455 | 1429 |
| |
1456 | 1430 |
| |
1457 |
| - | |
| 1431 | + | |
1458 | 1432 |
| |
1459 | 1433 |
| |
1460 | 1434 |
| |
| |||
1495 | 1469 |
| |
1496 | 1470 |
| |
1497 | 1471 |
| |
1498 |
| - | |
| 1472 | + | |
1499 | 1473 |
| |
1500 | 1474 |
| |
1501 | 1475 |
| |
| |||
1523 | 1497 |
| |
1524 | 1498 |
| |
1525 | 1499 |
| |
1526 |
| - | |
| 1500 | + | |
1527 | 1501 |
| |
1528 | 1502 |
| |
1529 | 1503 |
| |
1530 |
| - | |
1531 |
| - | |
1532 |
| - | |
1533 |
| - | |
1534 | 1504 |
| |
1535 |
| - | |
| 1505 | + | |
1536 | 1506 |
| |
1537 | 1507 |
| |
1538 | 1508 |
| |
| |||
1545 | 1515 |
| |
1546 | 1516 |
| |
1547 | 1517 |
| |
1548 |
| - | |
1549 |
| - | |
| 1518 | + | |
| 1519 | + | |
1550 | 1520 |
| |
1551 | 1521 |
| |
1552 | 1522 |
| |
| |||
1563 | 1533 |
| |
1564 | 1534 |
| |
1565 | 1535 |
| |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
1566 | 1549 |
| |
1567 | 1550 |
| |
1568 | 1551 |
| |
|
Lines changed: 2 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
772 | 772 |
| |
773 | 773 |
| |
774 | 774 |
| |
775 |
| - | |
776 |
| - | |
777 |
| - | |
| 775 | + | |
| 776 | + | |
778 | 777 |
| |
779 | 778 |
| |
780 | 779 |
| |
|
0 commit comments
Comments
(0)