Skip to content

[Feature]: efficient branch-head reads for root elements, related relationships and queries #416

Open

Description

@antoineatstariongroup

What type of issue is this?

  • Bug report
  • Feature request

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of the SysML2.NET
  • I have searched open and closed issues to ensure it has not already been reported

Description

The schema is designed for fast reads of each branch's latest state. Three PIM read operations still cost O(model) per call at a branch head (query shapes from schema.smoke.sql; not benchmarked):

  • getRootElements: reads the whole overlay plus checkpoint, then filters on derived_version.owner IS NULL. Nothing finds roots directly.
  • getRelationshipsByRelatedElement: no function provides the cheap path (reverse index ix_relationship_source_target / ix_relationship_target_target, then keep only versions current at the head), and the smoke script resolves the full snapshot instead.
  • executeQuery / executeQueryById: the vw_* views cover every version in history rather than the branch head, and only class_kind, owning_relationship, owner and qualified_name are indexed.

Reads at historical commits are slower by design and are out of scope.

Fix:

  • Add a root flag to branch_head and commit_checkpoint, with a partial index on it.
  • Add a branch-head relationships function built on the reverse indexes.
  • Add branch-head-scoped views or query helpers.
  • Add a case for each to SqlSchemaBenchmarkTestFixture.

Steps to Reproduce

Not applicable (performance feature). See the ROOTS and REVERSE-RELATIONSHIP scenarios in SysML2.NET.CodeGenerator.Tests/Sql/schema.smoke.sql.

System Configuration

  • SysML2.NET version: PR [ADD] Sql schema #344 (feat/sql-schema-and-more, d5a90f2), SysML2.NET.CodeGenerator
  • Environment (Operating system, version and so on): Windows 11
  • .NET Framework version: .NET 10
  • Additional information: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions