Skip to content

Optimize FindQuery.update() with partial writes - #843

Draft
lh0156 wants to merge 2 commits into
redis:mainfrom
lh0156:agent/find-query-update-777
Draft

Optimize FindQuery.update() with partial writes#843
lh0156 wants to merge 2 commits into
redis:mainfrom
lh0156:agent/find-query-update-777

Conversation

@lh0156

@lh0156 lh0156 commented Jul 26, 2026

Copy link
Copy Markdown

Summary

Implements #777 by updating matching records without materializing full Pydantic models.

What changed

  • Uses FT.SEARCH ... NOCONTENT to collect matching keys page by page.
  • Validates and serializes update values once, including Pydantic constraints and Redis OM storage conversions.
  • Uses partial HSET mappings for HashModel.
  • Uses path-level JSON.SET commands for JsonModel, including nested __ paths.
  • Preserves the use_transaction flag and returns the number of updated records.
  • Keeps query projections out of the key-only search and preserves KNN state when copying queries.
  • Documents the new return value.

Testing

  • pytest -q tests --ignore tests/test_benchmarks.py: 265 passed.
  • pytest -q tests/test_hash_model.py tests/test_json_model.py: 147 passed.
  • Generated sync tests for the new coverage plus Hash/JSON model tests: 157 passed.
  • ruff check and ruff format --check on changed source/tests.
  • python -m compileall -q aredis_om tests.
  • bandit -q -r aredis_om/model/model.py -s B608.

Redis Stack was run locally via Docker Compose for the integration tests; benchmark tests were excluded from the full run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant