Skip to content

Commit

Permalink
document efforts to intern column names
Browse files Browse the repository at this point in the history
  • Loading branch information
charlievieth committed Dec 8, 2024
1 parent 310ebf8 commit b38a9a0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sqlite3.go
Original file line number Diff line number Diff line change
Expand Up @@ -2457,6 +2457,10 @@ func (rc *SQLiteRows) Columns() []string {
if rc.s.s != nil && int(rc.nc) != len(rc.cols) {
rc.cols = make([]string, rc.nc)
for i := 0; i < int(rc.nc); i++ {
// NB(CEV): I put a lot of effort into interning the column names
// but the performance hit was 1-5%. That said, it reduced allocs
// significantly. The important lesson here was to make the string
// pool per-connection to reduce lock contention.
rc.cols[i] = C.GoString(C.sqlite3_column_name(rc.s.s, C.int(i)))
}
}
Expand Down

0 comments on commit b38a9a0

Please sign in to comment.