Skip to content

search(sqlite): two-level chained search 500s with 'Expression tree is too large (maximum depth 1000)' on wide intermediate sets #943

Description

@angela-helios

GET /Observation?encounter.patient.gender=female on the #448 benchmark dataset (~2,300 matching encounters) fails with HTTP 500:

Chained search resolution failed error=internal error in sqlite: Failed to prepare search query: Expression tree is too large (maximum depth 1000)

The chained-search resolver materializes the intermediate id set into the outer query; past ~1,000 terms SQLite refuses to prepare it. Reproduced identically on current main-equivalent code and on the partial-index branch — pre-existing, unrelated to index layout. Single-level chains and _has are unaffected on this dataset.

Likely fix: batch the id list (chunked OR/IN with UNION), or stage ids into a temp table and join.

Activity

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions