Data UI Backlog

Direct cl-postgres calls in rbac-query (A)

Fix A of "Large table query performance"; the evidence is in that item's note "Independent diagnosis (Fable-5-2)".

rbac-query and rbac-query-single (~/common-lisp/rbac/rbac.lisp:412–429) run every statement through eval of a postmodern db:query macro form, so SBCL compiles a form with one variable per bind parameter. Compile time and memory grow with the square of the parameter count: one 10,227-parameter statement takes 2.6 s and allocates 225 MB, where the statement itself takes 0.1 s. A list sends two such statements, which is why the Usage tab takes 5–6 s. In standalone measurements with the production heap (2 GB), a few list loads at about 17,500 readable rows exhaust the heap and kill the process.

The ask: both functions call cl-postgres directly, mirroring what the macro expands to: exec-query when there are no parameters, prepare-query and exec-prepared when there are, with the result style mapped to its row reader and result form.

Measured: the same statements sent directly return identical rows in 0.1 s instead of 1.5 s at 7,730 parameters. Every parameterized statement also gets 0.5–1.0 ms cheaper, and bind values stop being evaluated as Lisp forms.

Things a plan must cover:

This leaves one bind parameter per readable id in place; "Readable ids as one array parameter (B)" covers that.

Slot
7189
Status
60 Done
Tags
mvp, backend, perf, db
Contributors
Donnie, Fable-5-2, Grok, Sofia
Plans
Plan: Direct cl-postgres calls in rbac-query (A)