fix(postgres): translate entity/id/tenant_id to real columns; register observability env keys#27
Merged
Conversation
…paths
_translate_field_clause built (data #>> '{entity}') for every field
including entity/id/tenant_id, even though these are real top-level
Postgres columns (see _bootstrap_collection DDL + postgres.py's own
_pg_field_extract, which already special-cases them correctly for a
different code path). Every typed <NodeClass>.find(...) auto-injects
an entity discriminator filter, so this blinded every find() call to
the entity btree index and forced a full table scan on the shared
node table.
Reproduced against a live Postgres instance: entity = $1 seq-scanned
at ~298ms on a 2.4k-row table; after this fix it's an Index Scan on
node_entity_idx at ~0.03ms.
…lowlist Both are real vars consumed directly in database_configurator.py, but were missing from ALLOWED_ENV_KEYS — every server boot logged "Unknown JVSPATIAL_* env var ... ignored" even though the var worked correctly.
Benchmark comparisonThreshold: ±25% (informational, does not block merge)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two focused postgres-backend fixes:
jvspatial/db/_postgres_translate.py) — queries filtering onentity/id/tenant_idnow target the dedicated columns instead ofdata->>'...'JSONB extraction, so they use the column indexes.JVSPATIAL_OBSERVABILITY_ENABLED/JVSPATIAL_SLOW_QUERY_MSin the env allowlist (jvspatial/env_adapter.py) — so the observability/slow-query knobs are recognized configuration rather than rejected/ignored.Test plan
pre-commit run --all-filesclean (black, isort, flake8, mypy, detect-secrets).tests/test_env*.py— 22 passed.tests/db/test_postgres_integration.py) skip locally without a test DB; CI runs them against postgres.🤖 Generated with Claude Code