Commit Graph

957 Commits

Author SHA1 Message Date
Philipinho 123771e841 ms 2026-04-23 19:40:27 +01:00
Philipinho 8c21675a75 fix(base): update base.module import to renamed QueryCacheModule 2026-04-23 16:59:28 +01:00
Philipinho 02a78b2ec7 test(base): wire integration + parity specs to duckdb runtime 2026-04-23 16:58:16 +01:00
Philipinho dbc1eb539c fix(base): serialize writer operations and prune dead code in cache service 2026-04-23 16:50:11 +01:00
Philipinho 38cd94b2d7 refactor(base): single duckdb instance with per-base attached databases 2026-04-23 16:40:14 +01:00
Philipinho 4437dcbb62 feat(base): single-instance duckdb runtime with writer + reader pool 2026-04-23 16:23:24 +01:00
Philipinho 568d94be1f feat(base): schema-qualified query builder for single-instance duckdb 2026-04-23 16:19:47 +01:00
Philipinho f12a0675ea feat(base): schema-qualified loader sql for single-instance duckdb 2026-04-23 16:15:42 +01:00
Philipinho 838d8892f0 feat(base): minimal async connection pool for duckdb reader pool 2026-04-23 16:10:32 +01:00
Philipinho 08711791d6 feat(base): add baseSchemaName helper for duckdb schema naming 2026-04-23 16:05:45 +01:00
Philipinho b04bcb5b0c feat(base): env var for duckdb reader-pool size 2026-04-23 15:52:35 +01:00
Philipinho 709d927544 fix(base): declare primary key on loaded rows so upsert has a conflict target 2026-04-23 14:31:26 +01:00
Philipinho 5b96dfe6c9 feat(base): log duckdb heap + spill per base on cold load 2026-04-23 14:07:36 +01:00
Philipinho 17db634029 fix(base): enable duckdb disk spill + raise memory default to avoid oom on large bases 2026-04-23 13:56:31 +01:00
Philipinho 5ebab5cd9e fix(base): make cell-extractor pg functions genuinely parallel-safe
The plpgsql + EXCEPTION versions of base_cell_numeric,
base_cell_timestamptz, and base_cell_bool were labeled PARALLEL SAFE
but EXCEPTION blocks require subtransactions, which Postgres cannot
start in a parallel worker. Any parallel scan that invoked them
crashed with 'cannot start subtransactions during a parallel
operation' — notably DuckDB's postgres extension on large base COPY
reads.

Rewrite each as a pure SQL function using jsonb_typeof + regex
validation for the 'coerce-or-null' semantics. No plpgsql, no
subtransactions, genuinely parallel-safe. Signatures unchanged so
existing call sites (loader, expression indexes, engine predicates)
are untouched.
2026-04-23 13:52:20 +01:00
Philipinho 2d9e060d9e feat(base): add BASE_QUERY_CACHE_TRACE flag for duckdb operation logging 2026-04-23 13:37:25 +01:00
Philipinho b2ed8f9936 Revert "refactor(base): use uuid package instead of inlined uuid7 in tests"
This reverts commit f819f633c9.
2026-04-23 13:14:09 +01:00
Philipinho 7192b4bacb Revert "refactor(base): use uuid package validator in loader-sql"
This reverts commit cfc50b7cae.
2026-04-23 13:14:09 +01:00
Philipinho cfc50b7cae refactor(base): use uuid package validator in loader-sql 2026-04-23 13:09:25 +01:00
Philipinho f819f633c9 refactor(base): use uuid package instead of inlined uuid7 in tests 2026-04-23 13:07:19 +01:00
Philipinho db1b1464e2 test(base): assert pure-postgres path when query cache is disabled 2026-04-23 12:50:59 +01:00
Philipinho cc47a6d65c refactor(base): drop prepared binding now that loader sql inlines uuids 2026-04-23 12:39:33 +01:00
Philipinho 378d17350c fix(base): use postgres_query to invoke pg-side udfs from duckdb loader 2026-04-23 12:39:30 +01:00
Philipinho eea989260a test(base): filter/sort parity matrix against postgres
Integration spec that seeds a 10K-row base with diverse property shapes
(text, number, date, checkbox, select, multi-select) and runs an
exhaustive matrix of filter/sort combinations against both the DuckDB
cache path and the Postgres-direct path. Asserts identical row ids and,
where semantics allow, identical cursor strings and pagination meta.

The suite is gated by INTEGRATION_DB_URL and skips cleanly without it.
34 tests total: 26 flat filter ops (text/number/date/checkbox/select/
multi-select), 4 nested boolean trees (AND/OR/mixed/max-depth), 3
multi-key sorts, and one full filter+sort+pagination walk.

Seed tuning to keep both engines in lock-step:
  * digit-only row positions so PG default collation and DuckDB
    bytewise collation agree on the tail tiebreak.
  * lowercase name pool so mixed-case locale/bytewise divergence
    doesn't surface on text-secondary sort.
  * priority is non-NULL to avoid the PG keyset stall when a boundary
    cursor encodes the '+/-Infinity' numeric sentinel (postgres.js
    parses it as NaN, which applyCursor re-emits as null).
2026-04-23 05:00:17 +01:00
Philipinho fc08cffd37 test(server): init LRU test module so pg extension bootstraps 2026-04-23 04:40:30 +01:00
Philipinho fde0ccb3c7 refactor(base): replace streaming loader with pg-extension CREATE TABLE AS SELECT 2026-04-23 04:28:25 +01:00
Philipinho e663d7eecf test(server): align integration stubs with new config + pg-extension injection 2026-04-23 04:28:21 +01:00
Philipinho 96e875f1de test(base): tighten loader-sql mapping assertions to full projections 2026-04-23 03:37:23 +01:00
Philipinho 6544ff6d38 feat(base): pure SQL builder for pg-extension loader 2026-04-23 03:31:00 +01:00
Philipinho 7ca712c9ab fix(base): propagate pg-extension bootstrap failure reason; align closeSync style 2026-04-23 03:26:41 +01:00
Philipinho a798397af0 feat(base): postgres extension service with bootstrap install + per-connection attach 2026-04-23 03:17:36 +01:00
Philipinho 9ba6459427 feat(base): env vars for per-instance duckdb memory limit + threads 2026-04-23 03:09:58 +01:00
Philipinho 14827ec6a0 test(server): add getBaseQueryCacheDebug to integration test env stubs 2026-04-19 23:41:06 +01:00
Philipinho c931fa5ec9 perf(server): skip per-request row count when collection is resident 2026-04-19 23:39:27 +01:00
Philipinho 7e07d77510 chore(server): add per-request perf logs for base query cache diagnostics 2026-04-19 22:44:39 +01:00
Philipinho 55feb01249 test(server): assert duckdb cache matches postgres on a 100K-row base 2026-04-19 22:28:07 +01:00
Philipinho 4636af3870 feat(server): warm duckdb collections on boot from redis recent-access set 2026-04-19 22:16:20 +01:00
Philipinho c9adf84260 feat(server): evict least-recently-used duckdb collections when cap exceeded 2026-04-19 22:11:55 +01:00
Philipinho 4f38c61725 fix(server): avoid acquiring redis client when base query cache is disabled 2026-04-19 22:05:56 +01:00
Philipinho df22efb290 feat(server): propagate row mutations to duckdb cache via redis pubsub 2026-04-19 22:00:37 +01:00
Philipinho 7534b44e6e refactor(server): preserve cache-failure stack trace and reuse hasSearch 2026-04-19 21:50:34 +01:00
Philipinho cf6b48cd58 feat(server): route large base list queries through the duckdb cache 2026-04-19 21:46:27 +01:00
Philipinho 45000bbd8b fix(server): close duckdb resources on load failure, dedupe concurrent loads, drop unused cells projection 2026-04-19 21:39:05 +01:00
Philipinho 91ad3de258 feat(server): load bases into DuckDB and serve list queries from cache
- collection-loader streams base rows via postgres and bulk-inserts into an
  in-memory DuckDB instance using the Appender API, then builds an index on
  each indexable column
- base-query-cache service routes list() calls through the prepared-statement
  path; ensureLoaded does schema-version checks with single-pass LRU eviction
- keyset param-ordering bug in the DuckDB builder fixed: placeholders appear
  head-to-tail but were being pushed tail-to-head, which made DuckDB bind the
  wrong value for each ? and throw Binder Error on typed columns
- base-row repo gains countActiveRows for the router to use in task 6
- seed script split into an importable helper so integration tests can seed a
  10k-row base deterministically without shelling out
- new integration spec compares Postgres vs DuckDB pagination end-to-end for
  a numeric sort and guards against duplicate rows from DuckDB

Integration test is skipped unless INTEGRATION_DB_URL is set.
2026-04-19 21:31:05 +01:00
Philipinho b28597125d fix(server): use DuckDB json_contains for multi-select filters and expand builder coverage 2026-04-19 21:11:29 +01:00
Philipinho a9db3ef008 feat(server): add DuckDB SQL builder for base list queries 2026-04-19 21:06:41 +01:00
Philipinho 574c5316f0 feat(server): scaffold base query-cache module behind feature flag 2026-04-19 20:59:24 +01:00
Philipinho 3af2db7a8b feat(server): add property-type to DuckDB column-spec mapping 2026-04-19 20:54:59 +01:00
Philipinho f181c6d9e8 fix(server): case-insensitive parse for BASE_QUERY_CACHE_ENABLED env var 2026-04-19 20:52:06 +01:00
Philipinho 8ac4c97c98 docs(server): explain base-query-cache max-collections default 2026-04-19 20:50:21 +01:00