Skip to content

Conversation

@TimDiekmann
Copy link
Member

@TimDiekmann TimDiekmann commented Oct 31, 2025

🌟 What is the purpose of this PR?

This PR refactors the PostgreSQL query builder to improve the representation of table and column references. It introduces a more structured approach to handling SQL identifiers, table references, and join clauses, making the code more maintainable and type-safe.

🔍 What does this change?

  • Refactors join clauses to use a more structured approach with distinct variants for different join types
  • Improves handling of table and column aliases with proper quoting and escaping
  • Replaces the monolithic JoinExpression with a more flexible JoinClause enum
  • Restructures SelectExpression to properly handle both regular expressions and asterisk wildcards
  • Updates the query compiler to work with the new reference types
  • Adds proper support for row expansion in SQL expressions

🛡 What tests cover this?

  • Comprehensive unit tests for the new identifier, table reference, and column reference types
  • Tests for different join clause variants and their SQL transpilation
  • Existing integration tests continue to validate the overall query generation

## Documentation improvements

Add comprehensive rustdoc comments for query expression types:

- `ColumnReference`: Document fields and conversion from `Column`
- `TableReference`: Document schema hierarchy and alias behavior
- `JoinType`: Document join semantics and add `reverse()` method
- `JoinFrom`: Document table vs subquery sources

## JOIN expression refactoring

Convert `JoinExpression` from struct to enum to properly model PostgreSQL's
different join types with type-level invariants:

- `Conditioned`: INNER/LEFT/RIGHT/FULL OUTER with explicit ON conditions
- `Cross`: CROSS JOIN (cartesian product, no conditions)
- `Natural`: NATURAL JOIN (implicit column matching)

This prevents invalid states like CROSS JOIN with conditions at compile time.

## Bug fixes

- Fix schema information loss in `JoinFrom::transpile()` by calling
  `table.transpile()` instead of `table.name.transpile()`
- Add assertion to catch empty conditions in `Conditioned` variant
- Add helper methods `from_item()` and `from_item_mut()` for ergonomic access

## Tests

- Add tests for CROSS and NATURAL JOIN transpilation
- Add test to verify empty conditions panic behavior
- Add tests for `reference_table()` with/without alias
- All 146 existing tests continue to pass

Clippy clean with proper use of `Self`, merged match arms, and `#[expect]`
attributes for justified warnings.
Improve type safety for SQL wildcard handling by:

- Converting `SelectExpression` from struct to enum with:
  - `Expression { expression, alias }` for regular expressions
  - `Asterisk(Option<TableReference>)` for wildcards (* or table.*)

- Removing `Asterisk` from `ColumnName` enum to prevent it appearing
  in invalid SQL contexts (WHERE clauses, JOIN conditions, etc.)

- Adding `Expression::RowExpansion` for PostgreSQL's `(row).*` syntax
  used to expand composite types into columns

- Removing unused `Expression::FieldAccess` variant

This change enforces at the type level that asterisk wildcards can only
appear in SELECT clauses or as row expansions, not in expressions where
they would be invalid SQL.

All 146 tests pass.
Change `ColumnName` from a public enum to an opaque struct with:
- Private `ColumnNameImpl` enum containing `Static(Column)` and `Dynamic(Identifier)`
- `From` implementations for `Column` and `Identifier`
- `Transpile` and `Debug` implementations
- String-based equality and hashing (consistent with `TableName`)

This provides a cleaner API by hiding implementation details while
maintaining the same functionality. The internal representation can
now be changed without breaking external code.

Updated all usage sites in tests and `Column::aliased` to use `ColumnName::from`.
Align join clause naming with SQL keywords for consistency:
- Conditioned → On (matches JOIN ... ON syntax)
- Natural (already matches NATURAL JOIN)
- Cross (already matches CROSS JOIN)

This creates consistent, clear naming where all variants directly reflect
the SQL syntax they represent.
Extend JoinClause enum with a Using variant that supports PostgreSQL's
USING clause syntax for joins on matching column names.

The USING clause specifies column names that must exist in both tables
and PostgreSQL joins rows where these columns have equal values. The
specified columns appear only once in the result set.

Transpiles to: `<JOIN TYPE> "table" USING ("col1", "col2")`

This completes the set of JOIN clause types:
- On: explicit conditions with ON clause
- Using: matching column names with USING clause
- Cross: cartesian product
- Natural: implicit matching columns
- Add `lateral` boolean field to `JoinFrom::Subquery` for LATERAL subquery support
- Implement `join_using_alias` field in `JoinClause::Using` for PostgreSQL USING alias syntax
- Allow empty `conditions` in `On` variant to transpile to `ON TRUE` (cartesian product)
- Allow empty `columns` in `Using` variant to transpile to `ON TRUE` for consistency with NATURAL JOIN behavior
- Add `indoc` as dev-dependency for improved test readability
- Add comprehensive tests for LATERAL subqueries and join_using_alias
- Remove clippy warning suppression for empty USING joins (now semantically valid)

All 150 tests passing with 0 clippy warnings.
@github-actions github-actions bot added area/deps Relates to third-party dependencies (area) area/libs Relates to first-party libraries/crates/packages (area) type/eng > backend Owned by the @backend team labels Oct 31, 2025
@TimDiekmann TimDiekmann changed the title Use ColumnReference in expressions BE-188: Use ColumnReference in expressions and complete JoinClause Oct 31, 2025
@TimDiekmann TimDiekmann marked this pull request as ready for review October 31, 2025 17:11
@codecov
Copy link

codecov bot commented Oct 31, 2025

Codecov Report

❌ Patch coverage is 93.58289% with 72 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.06%. Comparing base (37c8768) to head (eacb301).

Files with missing lines Patch % Lines
...e/src/store/postgres/query/expression/from_item.rs 96.50% 16 Missing and 8 partials ⚠️
...postgres-store/src/store/postgres/query/compile.rs 90.47% 13 Missing and 3 partials ⚠️
...tore/postgres/query/expression/column_reference.rs 66.66% 12 Missing and 1 partial ⚠️
...store/src/store/postgres/query/statement/insert.rs 0.00% 12 Missing ⚠️
...e/src/store/postgres/query/expression/join_type.rs 71.42% 4 Missing ⚠️
...src/store/postgres/query/expression/conditional.rs 83.33% 2 Missing ⚠️
...store/src/store/postgres/query/statement/select.rs 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7963      +/-   ##
==========================================
+ Coverage   55.77%   56.06%   +0.28%     
==========================================
  Files        1116     1118       +2     
  Lines      101509   102147     +638     
  Branches     4701     4722      +21     
==========================================
+ Hits        56616    57264     +648     
+ Misses      44228    44210      -18     
- Partials      665      673       +8     
Flag Coverage Δ
apps.hash-ai-worker-ts 1.32% <ø> (ø)
apps.hash-api 0.00% <ø> (ø)
blockprotocol.type-system 40.84% <ø> (ø)
local.harpc-client 51.24% <ø> (ø)
local.hash-backend-utils 4.08% <ø> (ø)
local.hash-graph-sdk 10.88% <ø> (ø)
local.hash-isomorphic-utils 0.00% <ø> (ø)
rust.antsi 0.00% <ø> (ø)
rust.error-stack 90.85% <ø> (ø)
rust.harpc-codec 84.22% <ø> (ø)
rust.harpc-net 96.08% <ø> (-0.02%) ⬇️
rust.harpc-tower 66.80% <ø> (ø)
rust.harpc-types 0.00% <ø> (ø)
rust.harpc-wire-protocol 92.23% <ø> (ø)
rust.hash-codec 71.25% <ø> (ø)
rust.hash-graph-api 2.89% <ø> (ø)
rust.hash-graph-authorization 62.50% <ø> (ø)
rust.hash-graph-postgres-store 25.03% <93.58%> (+3.20%) ⬆️
rust.hash-graph-store 30.70% <ø> (ø)
rust.hash-graph-temporal-versioning 47.68% <ø> (ø)
rust.hash-graph-types 0.00% <ø> (ø)
rust.hash-graph-validation 83.29% <ø> (ø)
rust.hashql-ast 87.17% <ø> (ø)
rust.hashql-compiletest 53.03% <ø> (ø)
rust.hashql-core 81.27% <ø> (ø)
rust.hashql-diagnostics 72.28% <ø> (ø)
rust.hashql-eval 68.56% <ø> (ø)
rust.hashql-hir 90.29% <ø> (ø)
rust.hashql-syntax-jexpr 93.94% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@graphite-app
Copy link
Contributor

graphite-app bot commented Oct 31, 2025

Graphite Automations

"Request backend reviewers once CI passes" took an action on this PR • (10/31/25)

1 reviewer was added to this PR based on Tim Diekmann's automation.

"Request Rust reviewers once CI passes" took an action on this PR • (10/31/25)

1 reviewer was added to this PR based on Tim Diekmann's automation.

"Request DevOps reviewers once CI passes" took an action on this PR • (11/01/25)

1 reviewer was added to this PR based on Tim Diekmann's automation.

Base automatically changed from t/be-187-introduce-tablereference-and-refactor-joinexpression to main November 1, 2025 19:28
@graphite-app graphite-app bot requested a review from a team November 1, 2025 19:28
@graphite-app
Copy link
Contributor

graphite-app bot commented Nov 1, 2025

Merge activity

  • Nov 1, 7:28 PM UTC: This pull request can not be added to the Graphite merge queue. Please try rebasing and resubmitting to merge when ready.
  • Nov 1, 7:28 PM UTC: Graphite disabled "merge when ready" on this PR due to: a merge conflict with the target branch; resolve the conflict and try again..

@TimDiekmann TimDiekmann force-pushed the t/be-188-use-columnreference-in-expressions-and-complete-joinclause branch from 98db011 to eacb301 Compare November 1, 2025 21:10
@TimDiekmann TimDiekmann changed the title BE-188: Use ColumnReference in expressions and complete JoinClause BE-188: Use ColumnReference in expressions and merge JoinClause into FromItem Nov 1, 2025
@TimDiekmann TimDiekmann changed the title BE-188: Use ColumnReference in expressions and merge JoinClause into FromItem BE-188: Use ColumnReference in expressions and complete JoinClause Nov 1, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 3, 2025

Benchmark results

@rust/hash-graph-benches – Integrations

policy_resolution_large

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 2002 $$28.0 \mathrm{ms} \pm 165 \mathrm{μs}\left({\color{gray}-0.858 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$3.25 \mathrm{ms} \pm 14.5 \mathrm{μs}\left({\color{gray}-2.293 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 1001 $$12.5 \mathrm{ms} \pm 77.4 \mathrm{μs}\left({\color{lightgreen}-7.015 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 3314 $$42.0 \mathrm{ms} \pm 265 \mathrm{μs}\left({\color{gray}-2.459 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$13.8 \mathrm{ms} \pm 77.6 \mathrm{μs}\left({\color{gray}-4.147 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 1526 $$24.2 \mathrm{ms} \pm 152 \mathrm{μs}\left({\color{gray}-1.282 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 2078 $$27.5 \mathrm{ms} \pm 154 \mathrm{μs}\left({\color{lightgreen}-39.522 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.63 \mathrm{ms} \pm 16.6 \mathrm{μs}\left({\color{lightgreen}-40.287 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 1033 $$11.5 \mathrm{ms} \pm 65.1 \mathrm{μs}\left({\color{lightgreen}-65.290 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_medium

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 102 $$3.64 \mathrm{ms} \pm 16.8 \mathrm{μs}\left({\color{gray}-2.280 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.83 \mathrm{ms} \pm 12.6 \mathrm{μs}\left({\color{gray}-1.106 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 51 $$3.23 \mathrm{ms} \pm 17.5 \mathrm{μs}\left({\color{gray}-1.026 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 269 $$5.08 \mathrm{ms} \pm 28.4 \mathrm{μs}\left({\color{gray}-3.044 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$3.40 \mathrm{ms} \pm 16.4 \mathrm{μs}\left({\color{gray}-3.051 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 107 $$3.94 \mathrm{ms} \pm 15.4 \mathrm{μs}\left({\color{gray}-2.602 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 133 $$4.37 \mathrm{ms} \pm 22.5 \mathrm{μs}\left({\color{gray}0.411 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.27 \mathrm{ms} \pm 14.3 \mathrm{μs}\left({\color{gray}-1.724 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 63 $$3.90 \mathrm{ms} \pm 21.2 \mathrm{μs}\left({\color{gray}-0.797 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_none

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 2 $$2.48 \mathrm{ms} \pm 9.19 \mathrm{μs}\left({\color{gray}2.52 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.47 \mathrm{ms} \pm 9.84 \mathrm{μs}\left({\color{red}5.06 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 1 $$2.58 \mathrm{ms} \pm 12.1 \mathrm{μs}\left({\color{gray}4.40 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 8 $$2.75 \mathrm{ms} \pm 15.2 \mathrm{μs}\left({\color{gray}3.38 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.63 \mathrm{ms} \pm 11.7 \mathrm{μs}\left({\color{gray}4.39 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 3 $$2.81 \mathrm{ms} \pm 11.4 \mathrm{μs}\left({\color{gray}2.44 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_small

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 52 $$2.93 \mathrm{ms} \pm 13.5 \mathrm{μs}\left({\color{red}7.00 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.58 \mathrm{ms} \pm 9.59 \mathrm{μs}\left({\color{red}6.90 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 25 $$2.76 \mathrm{ms} \pm 10.4 \mathrm{μs}\left({\color{red}8.44 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 94 $$3.27 \mathrm{ms} \pm 20.0 \mathrm{μs}\left({\color{red}6.22 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$2.83 \mathrm{ms} \pm 13.8 \mathrm{μs}\left({\color{red}6.26 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 26 $$3.05 \mathrm{ms} \pm 15.5 \mathrm{μs}\left({\color{red}6.33 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 66 $$3.25 \mathrm{ms} \pm 16.1 \mathrm{μs}\left({\color{red}8.91 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.78 \mathrm{ms} \pm 11.2 \mathrm{μs}\left({\color{red}6.62 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 29 $$3.05 \mathrm{ms} \pm 14.8 \mathrm{μs}\left({\color{red}5.67 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_complete

Function Value Mean Flame graphs
entity_by_id;one_depth 1 entities $$37.9 \mathrm{ms} \pm 116 \mathrm{μs}\left({\color{gray}-1.579 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 10 entities $$84.3 \mathrm{ms} \pm 356 \mathrm{μs}\left({\color{gray}-2.012 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 25 entities $$41.9 \mathrm{ms} \pm 165 \mathrm{μs}\left({\color{gray}-2.165 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 5 entities $$45.8 \mathrm{ms} \pm 253 \mathrm{μs}\left({\color{gray}2.11 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 50 entities $$52.9 \mathrm{ms} \pm 238 \mathrm{μs}\left({\color{gray}-1.664 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 1 entities $$39.5 \mathrm{ms} \pm 153 \mathrm{μs}\left({\color{gray}-1.183 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 10 entities $$496 \mathrm{ms} \pm 952 \mathrm{μs}\left({\color{gray}0.953 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 25 entities $$96.5 \mathrm{ms} \pm 415 \mathrm{μs}\left({\color{gray}-1.538 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 5 entities $$83.0 \mathrm{ms} \pm 303 \mathrm{μs}\left({\color{gray}0.441 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 50 entities $$289 \mathrm{ms} \pm 695 \mathrm{μs}\left({\color{gray}0.177 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 1 entities $$14.9 \mathrm{ms} \pm 69.1 \mathrm{μs}\left({\color{gray}4.40 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 10 entities $$15.0 \mathrm{ms} \pm 61.9 \mathrm{μs}\left({\color{gray}1.48 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 25 entities $$15.2 \mathrm{ms} \pm 69.3 \mathrm{μs}\left({\color{gray}-0.234 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 5 entities $$15.0 \mathrm{ms} \pm 71.1 \mathrm{μs}\left({\color{gray}0.830 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 50 entities $$18.4 \mathrm{ms} \pm 91.8 \mathrm{μs}\left({\color{gray}-0.457 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_linkless

Function Value Mean Flame graphs
entity_by_id 1 entities $$14.4 \mathrm{ms} \pm 53.9 \mathrm{μs}\left({\color{gray}-0.991 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$14.6 \mathrm{ms} \pm 66.2 \mathrm{μs}\left({\color{gray}0.219 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 100 entities $$14.9 \mathrm{ms} \pm 77.3 \mathrm{μs}\left({\color{gray}0.895 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1000 entities $$15.7 \mathrm{ms} \pm 75.5 \mathrm{μs}\left({\color{gray}2.46 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10000 entities $$21.9 \mathrm{ms} \pm 151 \mathrm{μs}\left({\color{gray}-1.323 \mathrm{\%}}\right) $$ Flame Graph

representative_read_entity

Function Value Mean Flame graphs
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/block/v/1 $$30.2 \mathrm{ms} \pm 271 \mathrm{μs}\left({\color{gray}4.73 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1 $$29.2 \mathrm{ms} \pm 268 \mathrm{μs}\left({\color{gray}-2.787 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1 $$29.0 \mathrm{ms} \pm 270 \mathrm{μs}\left({\color{gray}-3.389 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1 $$29.7 \mathrm{ms} \pm 297 \mathrm{μs}\left({\color{gray}-2.893 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/page/v/2 $$29.0 \mathrm{ms} \pm 281 \mathrm{μs}\left({\color{gray}0.577 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1 $$28.9 \mathrm{ms} \pm 283 \mathrm{μs}\left({\color{gray}-1.759 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/playlist/v/1 $$28.6 \mathrm{ms} \pm 256 \mathrm{μs}\left({\color{gray}-3.859 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1 $$29.5 \mathrm{ms} \pm 309 \mathrm{μs}\left({\color{gray}-4.964 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1 $$29.3 \mathrm{ms} \pm 275 \mathrm{μs}\left({\color{gray}-4.270 \mathrm{\%}}\right) $$ Flame Graph

representative_read_entity_type

Function Value Mean Flame graphs
get_entity_type_by_id Account ID: bf5a9ef5-dc3b-43cf-a291-6210c0321eba $$8.83 \mathrm{ms} \pm 34.5 \mathrm{μs}\left({\color{gray}-0.851 \mathrm{\%}}\right) $$ Flame Graph

representative_read_multiple_entities

Function Value Mean Flame graphs
entity_by_property traversal_paths=0 0 $$55.9 \mathrm{ms} \pm 300 \mathrm{μs}\left({\color{gray}-1.104 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=255 1,resolve_depths=inherit:1;values:255;properties:255;links:127;link_dests:126;type:true $$107 \mathrm{ms} \pm 375 \mathrm{μs}\left({\color{gray}-1.820 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:0;link_dests:0;type:false $$62.1 \mathrm{ms} \pm 290 \mathrm{μs}\left({\color{gray}0.623 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:1;link_dests:0;type:true $$70.7 \mathrm{ms} \pm 371 \mathrm{μs}\left({\color{gray}-0.394 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:2;links:1;link_dests:0;type:true $$79.5 \mathrm{ms} \pm 367 \mathrm{μs}\left({\color{gray}-1.676 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:2;properties:2;links:1;link_dests:0;type:true $$86.3 \mathrm{ms} \pm 414 \mathrm{μs}\left({\color{gray}-1.547 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=0 0 $$51.1 \mathrm{ms} \pm 303 \mathrm{μs}\left({\color{gray}-2.028 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=255 1,resolve_depths=inherit:1;values:255;properties:255;links:127;link_dests:126;type:true $$78.8 \mathrm{ms} \pm 291 \mathrm{μs}\left({\color{gray}-1.214 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:0;link_dests:0;type:false $$58.1 \mathrm{ms} \pm 341 \mathrm{μs}\left({\color{gray}-2.908 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:1;link_dests:0;type:true $$65.5 \mathrm{ms} \pm 361 \mathrm{μs}\left({\color{gray}-1.472 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:2;links:1;link_dests:0;type:true $$68.0 \mathrm{ms} \pm 299 \mathrm{μs}\left({\color{gray}-1.885 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:2;properties:2;links:1;link_dests:0;type:true $$67.9 \mathrm{ms} \pm 349 \mathrm{μs}\left({\color{gray}-1.885 \mathrm{\%}}\right) $$

scenarios

Function Value Mean Flame graphs
full_test query-limited $$140 \mathrm{ms} \pm 567 \mathrm{μs}\left({\color{gray}-0.488 \mathrm{\%}}\right) $$ Flame Graph
full_test query-unlimited $$133 \mathrm{ms} \pm 481 \mathrm{μs}\left({\color{gray}-4.470 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-limited $$41.7 \mathrm{ms} \pm 169 \mathrm{μs}\left({\color{lightgreen}-59.644 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-unlimited $$575 \mathrm{ms} \pm 1.15 \mathrm{ms}\left({\color{lightgreen}-7.556 \mathrm{\%}}\right) $$ Flame Graph

@TimDiekmann TimDiekmann added this pull request to the merge queue Nov 3, 2025
Merged via the queue into main with commit 519794b Nov 3, 2025
162 checks passed
@TimDiekmann TimDiekmann deleted the t/be-188-use-columnreference-in-expressions-and-complete-joinclause branch November 3, 2025 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/deps Relates to third-party dependencies (area) area/libs Relates to first-party libraries/crates/packages (area) type/eng > backend Owned by the @backend team

Development

Successfully merging this pull request may close these issues.

3 participants