forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit3592e0f
committed
Have ExecFindPartition cache the last found partition
Here we add code which detects when ExecFindPartition() continually findsthe same partition and add a caching layer to improve partition lookupperformance for such cases.Both RANGE and LIST partitioned tables traditionally require a binarysearch for the set of Datums that a partition needs to be found for. Thisbinary search is commonly visible in profiles when bulk loading into apartitioned table. Here we aim to reduce the overhead of bulk-loadinginto partitioned tables for cases where many consecutive tuples belong tothe same partition and make the performance of this operation closer towhat it is with a traditional non-partitioned table.When we find the same partition 16 times in a row, the next search willresult in us simply just checking if the current set of values belongs tothe last found partition. For LIST partitioning we record the index intothe PartitionBoundInfo's datum array. This allows us to check if thecurrent Datum is the same as the Datum that was last looked up. Thismeans if any given LIST partition supports storing multiple differentDatum values, then the caching only works when we find the same value aswe did the last time. For RANGE partitioning we simply check if the givenDatums are in the same range as the previously found partition.We store the details of the cached partition in PartitionDesc (i.e.relcache) so that the cached values are maintained over multiplestatements.No caching is done for HASH partitions. The majority of the cost in HASHpartition lookups are in the hashing function(s), which would also have tobe executed if we were to try to do caching for HASH partitioned tables.Since most of the cost is already incurred, we just don't bother. We alsodon't do any caching for LIST partitions when we continually find thevalues being looked up belong to the DEFAULT partition. We've nocorresponding index in the PartitionBoundInfo's datum array for this case.We also don't cache when we find the given values match to a LISTpartitioned table's NULL partition. This is so cheap that there's nopoint in doing any caching for this. We also don't cache for a RANGEpartitioned table's DEFAULT partition.There have been a number of different patches submitted to improvepartition lookups. Hou, Zhijie submitted a patch to detect when the valuebelonging to the partition key column(s) were constant and added code tocache the partition in that case. Amit Langote then implemented an ideasuggested by me to remember the last found partition and start to check ifthe current values work for that partition. The final patch here waswritten by me and was done by taking many of the ideas I liked from thepatches in the thread and redesigning other aspects.Discussion:https://postgr.es/m/OS0PR01MB571649B27E912EA6CC4EEF03942D9%40OS0PR01MB5716.jpnprd01.prod.outlook.comAuthor: Amit Langote, Hou Zhijie, David RowleyReviewed-by: Amit Langote, Hou Zhijie1 parent83f1793 commit3592e0f
File tree
3 files changed
+204
-19
lines changed- src
- backend
- executor
- partitioning
- include/partitioning
3 files changed
+204
-19
lines changedLines changed: 173 additions & 19 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1332 | 1332 |
| |
1333 | 1333 |
| |
1334 | 1334 |
| |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
1335 | 1342 |
| |
1336 | 1343 |
| |
1337 | 1344 |
| |
1338 |
| - | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
1339 | 1378 |
| |
1340 | 1379 |
| |
1341 | 1380 |
| |
1342 | 1381 |
| |
1343 | 1382 |
| |
1344 | 1383 |
| |
1345 | 1384 |
| |
1346 |
| - | |
| 1385 | + | |
1347 | 1386 |
| |
1348 | 1387 |
| |
1349 | 1388 |
| |
1350 | 1389 |
| |
1351 | 1390 |
| |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
1352 | 1403 |
| |
1353 | 1404 |
| |
1354 | 1405 |
| |
1355 | 1406 |
| |
1356 | 1407 |
| |
1357 | 1408 |
| |
1358 | 1409 |
| |
| 1410 | + | |
1359 | 1411 |
| |
1360 | 1412 |
| |
1361 | 1413 |
| |
1362 | 1414 |
| |
1363 | 1415 |
| |
1364 |
| - | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
1365 | 1421 |
| |
1366 |
| - | |
1367 | 1422 |
| |
1368 | 1423 |
| |
1369 | 1424 |
| |
1370 | 1425 |
| |
| 1426 | + | |
1371 | 1427 |
| |
1372 |
| - | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
1373 | 1441 |
| |
1374 | 1442 |
| |
1375 | 1443 |
| |
1376 |
| - | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
1377 | 1463 |
| |
1378 | 1464 |
| |
1379 | 1465 |
| |
| |||
1403 | 1489 |
| |
1404 | 1490 |
| |
1405 | 1491 |
| |
1406 |
| - | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
1407 | 1497 |
| |
1408 |
| - | |
1409 |
| - | |
1410 |
| - | |
1411 |
| - | |
1412 |
| - | |
1413 |
| - | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
1414 | 1510 |
| |
1415 | 1511 |
| |
1416 |
| - | |
1417 |
| - | |
1418 |
| - | |
1419 |
| - | |
| 1512 | + | |
| 1513 | + | |
1420 | 1514 |
| |
1421 |
| - | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
1422 | 1534 |
| |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
1423 | 1550 |
| |
1424 | 1551 |
| |
1425 | 1552 |
| |
| |||
1433 | 1560 |
| |
1434 | 1561 |
| |
1435 | 1562 |
| |
1436 |
| - | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
1437 | 1591 |
| |
1438 | 1592 |
| |
1439 | 1593 |
| |
|
Lines changed: 6 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
290 | 290 |
| |
291 | 291 |
| |
292 | 292 |
| |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
293 | 299 |
| |
294 | 300 |
| |
295 | 301 |
| |
|
Lines changed: 25 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
36 | 36 |
| |
37 | 37 |
| |
38 | 38 |
| |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
39 | 64 |
| |
40 | 65 |
| |
41 | 66 |
| |
|
0 commit comments
Comments
(0)