Commit 3fda4b0
perf(table): reuse RowScanner across Iter rows
Iter created a fresh scany RowScanner per row via pgxscan.API.ScanRow,
recomputing the column-to-field mapping on every iteration. Create one
RowScanner before the loop and reuse it so the reflection work happens
once per query instead of once per row.
Benchmarked via BenchmarkTableIter (in-memory fake pgx.Rows), count=8:
rows=1000 time 394.8µs -> 177.5µs (-55%)
B/op 406.6Ki -> 63.2Ki (-84%)
allocs 6002 -> 1008 (-83%, ~6/row -> ~1/row)
All deltas p=0.000. GetAll/List/pagination already reuse a single
RowScanner internally, so this only affects the Iter streaming path.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 33be518 commit 3fda4b0
1 file changed
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
565 | 565 | | |
566 | 566 | | |
567 | 567 | | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
568 | 573 | | |
569 | 574 | | |
570 | 575 | | |
| 576 | + | |
571 | 577 | | |
572 | 578 | | |
573 | | - | |
| 579 | + | |
574 | 580 | | |
575 | 581 | | |
576 | 582 | | |
| |||
0 commit comments