Skip to content

SchemaView performance improvements#1479

Open
rschili wants to merge 18 commits into
mainfrom
rschili/schema-view-fragment
Open

SchemaView performance improvements#1479
rschili wants to merge 18 commits into
mainfrom
rschili/schema-view-fragment

Conversation

@rschili

@rschili rschili commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

itwinjs-core: iTwin/itwinjs-core#9431

New schema view fragment pragma that will be used by iTwinjs-core to load just subsets of an iModels' schema.
Plus a few fixes, please read the linked itwinjs-core PR description and issue for full details.

// A PRAGMA (or any statement FormatQuery left unwrapped) has no LIMIT/OFFSET parameters. Use the
// non-logging TryGetParameterIndex so probing for their absence does not emit "No
// parameter index found" errors - GetParameterIndex would log one per missing parameter.
const auto idxCount = stmt.TryGetParameterIndex(LIMIT_VAR_COUNT);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@khanaffan are you okay with this change?
The previous code was logging a warning because pragma going through concurrent query does not have those two parameters.
This change makes it so we don't log those warnings anymore.
Unrelated change, sneaking it in because it's small and insignificant.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends ECDb’s ECSQL pragma surface to support incremental SchemaView loading (fragments) for iTwinjs-core, and introduces a cheap schema identity hash (schema_token) intended for cache invalidation and determinism checks.

Changes:

  • Add PRAGMA schema_view_fragment(...) to return a subset of schemas as a SchemaView-format blob for incremental loading.
  • Add PRAGMA checksum(schema_token) backed by a new “name+version only” schema identity hash, and align schema_view’s schemaToken with it.
  • Refactor/extend SchemaViewWriter to support fragment filtering and safer state reuse; reduce noisy parameter-missing logs in concurrent query limit binding.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
iModelCore/ECDb/Tests/NonPublished/ECSqlPragmasTests.cpp Updates checksum/token assertions and adds coverage for schema_token and schema_view_fragment behavior.
iModelCore/ECDb/ECDb/SchemaViewWriter.h Adds fragment-related API/state and clarifies non-concurrent instance usage.
iModelCore/ECDb/ECDb/SchemaViewWriter.cpp Implements fragment filtering, request validation, centralized reset, and safer narrowing for serialized fields.
iModelCore/ECDb/ECDb/ECSql/ECSqlPragmas.h Extends checksum docs/options and declares schema_view_fragment + schema-token hashing support.
iModelCore/ECDb/ECDb/ECSql/ECSqlPragmas.cpp Implements checksum(schema_token), shared schema_view row building, and schema_view_fragment argument parsing.
iModelCore/ECDb/ECDb/ECDbImpl.cpp Registers the new schema_view_fragment pragma handler.
iModelCore/ECDb/ECDb/ConcurrentQueryManagerImpl.cpp Uses TryGetParameterIndex to avoid log spam when LIMIT/OFFSET params don’t exist (e.g., PRAGMAs).

Comment thread iModelCore/ECDb/ECDb/ECSql/ECSqlPragmas.cpp Outdated
Comment thread iModelCore/ECDb/ECDb/ECSql/ECSqlPragmas.cpp Outdated
rschili and others added 2 commits June 26, 2026 12:37
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@rschili
rschili marked this pull request as ready for review July 23, 2026 15:57
@rschili
rschili enabled auto-merge (squash) July 24, 2026 09:43
@rschili
rschili disabled auto-merge July 24, 2026 09:43
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.

3 participants