forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit2f5b8eb
committed
Clean up some ad-hoc code for sorting and de-duplicating Lists.
heap.c and relcache.c contained nearly identical copies of logicto insert OIDs into an OID list while preserving the list's OIDordering (and rejecting duplicates, in one case but not the other).The comments argue that this is faster than qsort for small numbersof OIDs, which is at best unproven, and seems even less likely to betrue now that lappend_cell_oid has to move data around. In any caseit's ugly and hard-to-follow code, and if we do have a lot of OIDsto consider, it's O(N^2).Hence, replace with simply lappend'ing OIDs to a List, then list_sortthe completed List, then remove adjacent duplicates if necessary.This is demonstrably O(N log N) and it's much simpler for thecallers. It's possible that this would be somewhat inefficientif there were a very large number of duplicates, but that seemsunlikely in the existing usage.This adds list_deduplicate_oid and list_oid_cmp infrastructureto list.c. I didn't bother with equivalent functionality forinteger or pointer Lists, but such could always be added laterif we find a use for it.Discussion:https://postgr.es/m/26193.1563228600@sss.pgh.pa.us1 parent569ed7f commit2f5b8eb
File tree
4 files changed
+63
-80
lines changed- src
- backend
- catalog
- nodes
- utils/cache
- include/nodes
4 files changed
+63
-80
lines changedLines changed: 6 additions & 43 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
125 | 125 |
| |
126 | 126 |
| |
127 | 127 |
| |
128 |
| - | |
129 | 128 |
| |
130 | 129 |
| |
131 | 130 |
| |
| |||
3384 | 3383 |
| |
3385 | 3384 |
| |
3386 | 3385 |
| |
3387 |
| - | |
| 3386 | + | |
3388 | 3387 |
| |
3389 |
| - | |
| 3388 | + | |
3390 | 3389 |
| |
3391 | 3390 |
| |
3392 | 3391 |
| |
3393 | 3392 |
| |
3394 | 3393 |
| |
3395 |
| - | |
3396 |
| - | |
| 3394 | + | |
| 3395 | + | |
| 3396 | + | |
3397 | 3397 |
| |
3398 |
| - | |
3399 |
| - | |
3400 |
| - | |
3401 |
| - | |
3402 |
| - | |
3403 |
| - | |
3404 |
| - | |
3405 |
| - | |
3406 |
| - | |
3407 |
| - | |
3408 |
| - | |
3409 |
| - | |
3410 |
| - | |
3411 |
| - | |
3412 |
| - | |
3413 |
| - | |
3414 |
| - | |
3415 |
| - | |
3416 |
| - | |
3417 |
| - | |
3418 |
| - | |
3419 |
| - | |
3420 |
| - | |
3421 |
| - | |
3422 |
| - | |
3423 |
| - | |
3424 |
| - | |
3425 |
| - | |
3426 |
| - | |
3427 |
| - | |
3428 |
| - | |
3429 |
| - | |
3430 |
| - | |
3431 |
| - | |
3432 |
| - | |
3433 |
| - | |
3434 |
| - | |
3435 |
| - | |
| 3398 | + | |
3436 | 3399 |
| |
3437 | 3400 |
| |
3438 | 3401 |
| |
|
Lines changed: 44 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1297 | 1297 |
| |
1298 | 1298 |
| |
1299 | 1299 |
| |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
1300 | 1328 |
| |
1301 | 1329 |
| |
1302 | 1330 |
| |
| |||
1444 | 1472 |
| |
1445 | 1473 |
| |
1446 | 1474 |
| |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + |
Lines changed: 9 additions & 37 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
285 | 285 |
| |
286 | 286 |
| |
287 | 287 |
| |
288 |
| - | |
289 | 288 |
| |
290 | 289 |
| |
291 | 290 |
| |
| |||
4387 | 4386 |
| |
4388 | 4387 |
| |
4389 | 4388 |
| |
4390 |
| - | |
4391 |
| - | |
| 4389 | + | |
| 4390 | + | |
4392 | 4391 |
| |
4393 | 4392 |
| |
4394 | 4393 |
| |
| |||
4413 | 4412 |
| |
4414 | 4413 |
| |
4415 | 4414 |
| |
| 4415 | + | |
| 4416 | + | |
| 4417 | + | |
4416 | 4418 |
| |
4417 | 4419 |
| |
4418 | 4420 |
| |
| |||
4494 | 4496 |
| |
4495 | 4497 |
| |
4496 | 4498 |
| |
4497 |
| - | |
| 4499 | + | |
4498 | 4500 |
| |
4499 | 4501 |
| |
4500 | 4502 |
| |
4501 | 4503 |
| |
4502 | 4504 |
| |
4503 | 4505 |
| |
| 4506 | + | |
| 4507 | + | |
| 4508 | + | |
4504 | 4509 |
| |
4505 | 4510 |
| |
4506 | 4511 |
| |
| |||
4515 | 4520 |
| |
4516 | 4521 |
| |
4517 | 4522 |
| |
4518 |
| - | |
4519 |
| - | |
4520 |
| - | |
4521 |
| - | |
4522 |
| - | |
4523 |
| - | |
4524 |
| - | |
4525 |
| - | |
4526 |
| - | |
4527 |
| - | |
4528 |
| - | |
4529 |
| - | |
4530 |
| - | |
4531 |
| - | |
4532 |
| - | |
4533 |
| - | |
4534 |
| - | |
4535 |
| - | |
4536 |
| - | |
4537 |
| - | |
4538 |
| - | |
4539 |
| - | |
4540 |
| - | |
4541 |
| - | |
4542 |
| - | |
4543 |
| - | |
4544 |
| - | |
4545 |
| - | |
4546 |
| - | |
4547 |
| - | |
4548 |
| - | |
4549 |
| - | |
4550 |
| - | |
4551 | 4523 |
| |
4552 | 4524 |
| |
4553 | 4525 |
| |
|
Lines changed: 4 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
563 | 563 |
| |
564 | 564 |
| |
565 | 565 |
| |
| 566 | + | |
| 567 | + | |
566 | 568 |
| |
567 | 569 |
| |
568 | 570 |
| |
| |||
573 | 575 |
| |
574 | 576 |
| |
575 | 577 |
| |
| 578 | + | |
| 579 | + | |
576 | 580 |
|
0 commit comments
Comments
(0)