Skip to content

BE-596: Materialize entity aggregates into entity_edition_cache#8854

Open
TimDiekmann wants to merge 6 commits into
mainfrom
t/be-596-materialize-the-aggregate-views-in-the-entity-subgraph-query
Open

BE-596: Materialize entity aggregates into entity_edition_cache#8854
TimDiekmann wants to merge 6 commits into
mainfrom
t/be-596-materialize-the-aggregate-views-in-the-entity-subgraph-query

Conversation

@TimDiekmann

@TimDiekmann TimDiekmann commented Jun 11, 2026

Copy link
Copy Markdown
Member

🌟 What is the purpose of this PR?

The entity-type aggregate views dominated queryEntitySubgraph runtime: every type filter/sort multiplied rows through entity_is_of_type ⋈ ontology joins and forced DISTINCT ON. This PR materializes the per-edition aggregates into a new entity_edition_cache table maintained on the write path. Entities-table page query on a 1.9M-edition dataset: ~130s → ~14s.

🔗 Related links

🔍 What does this change?

  • New entity_edition_cache table: direct_types count + parallel arrays labels, type_titles, base_urls, versions, versioned_urls (all inheritance depths, canonical ordering; direct types as array prefix), GIN on base_urls/versioned_urls
  • Migrations in both systems: production V51 (create + backfill + drop the 7 aggregate views), test-only v009 updated inline
  • Write path populates the cache on entity creation, snapshot restore, and entity-type reindex (reindex_entity_cache)
  • Read path uses the cache: Relation::EntityEditionCache, TypeVersionedUrls/DirectTypeCount paths, (labels)[1] via Expression::ArrayElement; HashQL projections unnest from the cache
  • Nullable TEXT sort keys decode via Option<CursorField>; Last* DESC-flip variants removed
  • Behaviour change: typeBaseUrls (and the email-masking rule built on it) is now inheritance-aware — the dropped entity_is_of_type_ids view only listed direct types. Entities whose direct type inherits from user now get email masking applied; previously their email was exposed.

Pre-Merge Checklist 🚀

🚢 Has this modified a publishable library?

This PR:

  • does not modify any publishable blocks or libraries, or modifications do not need publishing

📜 Does this require a change to the docs?

The changes in this PR:

  • are internal and do not require a docs change

🕸️ Does this require a change to the Turbo Graph?

The changes in this PR:

  • do not affect the execution graph

⚠️ Known issues

  • Rolling deploy: writes between the V51 backfill and the code going live miss the cache — run reindex-cache --entities once post-deploy (noted in the migration)
  • Dedicated integration tests for the cache (inheritance round-trip, reindex equivalence, label fixtures) follow separately

🐾 Next steps

  • BE-597 (array type filters), BE-598 (keys-then-hydrate), BE-599 (summary aggregations in SQL), BE-600 (filter selectivity)

🛡 What tests cover this?

  • Existing suites green (256 lib, 95 insta, 59 compiletest; clippy clean); both migration chains validated up+down
  • Backfill validated for result equivalence against the dropped views on a 1.9M-edition dataset (0 mismatches)

❓ How to test this?

  1. Run migrate against an existing database — the backfill populates entity_edition_cache
  2. Query entities with type filters, label/type-title sorting, includeTypeIds — identical results, no aggregate-view joins in the compiled SQL
  3. cd tests/graph/http && sh test.sh

Replaces the seven per-row aggregate views (labels, type titles, type
IDs) with a denormalized edition-keyed cache table. Arrays cover all
inheritance depths in canonical order (depth, title, base URL, version
DESC) with the direct types as prefix (direct_types); labels resolve per
direct type through the closed schema (nearest ancestor first).
Populated transactionally on entity writes via a shared statement
template, rebuilt by reindex_entity_cache (now also chained to
reindex_entity_type_cache), and backfilled in V51. The query compiler,
projection decode, and HashQL lateral read the cache; descending sorts
reuse the first element instead of flipping to last_* views. Nullable
sort keys (entity label) surface through the cursor decode as the
IS-NULL sentinel.
@vercel

vercel Bot commented Jun 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hash Ready Ready Preview, Comment Jun 11, 2026 4:25pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
hashdotdesign-tokens Ignored Ignored Preview Jun 11, 2026 4:25pm
petrinaut Skipped Skipped Jun 11, 2026 4:25pm

@github-actions github-actions Bot added area/libs Relates to first-party libraries/crates/packages (area) type/eng > backend Owned by the @backend team area/tests New or updated tests labels Jun 11, 2026
@TimDiekmann TimDiekmann changed the title BE-596: Materialize entity aggregates into entity_edition_cache BE-596: Materialize entity aggregates into entity_edition_cache Jun 11, 2026
@TimDiekmann TimDiekmann changed the title BE-596: Materialize entity aggregates into entity_edition_cache BE-596: Materialize entity aggregates into entity_edition_cache Jun 11, 2026
@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.81871% with 67 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.17%. Comparing base (232b539) to head (db769d6).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
...h/postgres-store/src/store/postgres/query/table.rs 45.83% 13 Missing ⚠️
...store/src/store/postgres/knowledge/entity/query.rs 0.00% 12 Missing ⚠️
libs/@local/graph/store/src/entity/query.rs 0.00% 9 Missing ⚠️
...s-store/src/store/postgres/knowledge/entity/mod.rs 66.66% 8 Missing ⚠️
.../postgres-store/src/store/postgres/query/entity.rs 65.21% 8 Missing ⚠️
...aph/postgres-store/src/store/postgres/query/mod.rs 0.00% 7 Missing ⚠️
.../graph/postgres-store/src/snapshot/entity/batch.rs 0.00% 6 Missing ⚠️
...postgres-store/src/store/postgres/query/compile.rs 83.33% 1 Missing and 1 partial ⚠️
libs/@local/graph/store/src/filter/protection.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8854      +/-   ##
==========================================
+ Coverage   59.13%   59.17%   +0.04%     
==========================================
  Files        1346     1346              
  Lines      130096   130111      +15     
  Branches     5883     5885       +2     
==========================================
+ Hits        76931    76995      +64     
+ Misses      52259    52210      -49     
  Partials      906      906              
Flag Coverage Δ
apps.hash-ai-worker-ts 1.39% <ø> (ø)
apps.hash-api 0.00% <ø> (ø)
local.hash-backend-utils 2.81% <ø> (ø)
local.hash-graph-sdk 9.63% <ø> (ø)
local.hash-isomorphic-utils 0.00% <ø> (ø)
rust.hash-graph-api 2.51% <ø> (ø)
rust.hash-graph-postgres-store 27.05% <56.25%> (+0.30%) ⬆️
rust.hash-graph-store 37.84% <0.00%> (+0.08%) ⬆️
rust.hash-graph-validation 83.43% <ø> (ø)
rust.hashql-compiletest 28.26% <ø> (ø)
rust.hashql-eval 75.72% <100.00%> (+0.03%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 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.

Comment thread libs/@local/graph/store/src/entity/query.rs Fixed
Convert the SQL template into
insert_entity_edition_cache_statement(scoped:
bool) to inline scoped filters for types and labels. Add unit tests to
verify scoped/unscoped occurrence counts and that the jsonb
text-extraction
operator's braces survive format! escaping. Also consolidate duplicate
match arms for TypeBaseUrls/TypeVersionedUrls into a single vector type
@vercel vercel Bot temporarily deployed to Preview – petrinaut June 11, 2026 14:16 Inactive
@vercel vercel Bot temporarily deployed to Preview – petrinaut June 11, 2026 14:20 Inactive
@TimDiekmann TimDiekmann marked this pull request as ready for review June 11, 2026 14:33
@TimDiekmann TimDiekmann requested a review from a team as a code owner June 11, 2026 14:33
Copilot AI review requested due to automatic review settings June 11, 2026 14:33
@cursor

cursor Bot commented Jun 11, 2026

Copy link
Copy Markdown

PR Summary

High Risk
Large schema/migration with rolling-deploy cache gaps, intentional masking semantics change for inherited types, and broad query-path changes across Postgres store and HashQL.

Overview
Replaces per-row Postgres aggregate views (entity_is_of_type_ids, label/title views) with a materialized entity_edition_cache table so entity subgraph queries do a single 1:1 join instead of re-aggregating types and labels per row.

The cache stores direct_types plus aligned arrays (labels, type_titles, base_urls, versions, versioned_urls) with GIN indexes on type URL arrays for @> filters. V51 backfills and drops the seven views; test migrations mirror the schema. Writes populate or rebuild the cache on edition insert, snapshot commit, property normalization, inherited-type reindex, and entity-type cache reindex.

The query compiler and HashQL now read EntityEditionCache: TypeVersionedUrls / DirectTypeCount, (labels)[1] / (type_titles)[1] via new ArrayElement SQL; Last* sort paths and DESC min/max flipping are removed. Nullable label sort cursors use Option<CursorField>.

Behaviour change: typeBaseUrls (and email masking built on it) is inheritance-aware—supertypes appear in base_urls, not only direct types as the old view did.

Reviewed by Cursor Bugbot for commit db769d6. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 72a957f. Configure here.

Comment thread libs/@local/graph/postgres-store/src/store/postgres/ontology/entity_type.rs Outdated
Comment thread libs/@local/graph/postgres-store/src/snapshot/entity/batch.rs
Comment thread libs/@local/graph/postgres-store/src/store/postgres/query/entity.rs

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 introduces a denormalized entity_edition_cache table to materialize per-entity-edition type/label aggregates on the write path, replacing several expensive aggregate views to significantly reduce queryEntitySubgraph latency.

Changes:

  • Add entity_edition_cache (migrations + write-path population + reindex support) and drop legacy aggregate views.
  • Update read/query compilation paths to source type IDs, type-title/label sort keys, and type containment filtering from the cache (including array element access and ordinality-restricted unnesting).
  • Update Postgres query cursor decoding to tolerate nullable sort keys (e.g. unlabeled entities).

Reviewed changes

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

Show a summary per file
File Description
libs/@local/hashql/eval/tests/ui/postgres/filter/provides_drives_select_and_joins.snap Snapshot update: HashQL SQL now joins entity_edition_cache and restricts unnested rows via ordinality/direct_types.
libs/@local/hashql/eval/tests/ui/postgres/filter/property_mask.snap Snapshot update: same cache-based join/unnest changes.
libs/@local/hashql/eval/tests/ui/postgres/filter/data_island_provides_without_lateral.snap Snapshot update: same cache-based join/unnest changes.
libs/@local/hashql/eval/tests/ui/postgres/entity-type-ids-lateral.stdout Snapshot update: lateral type-id projection now uses cache + ordinality filter.
libs/@local/hashql/eval/src/postgres/projections.rs Update HashQL entity_type_ids lateral projection to source from cache and filter to direct-type prefix.
libs/@local/graph/store/src/filter/protection.rs Adjust protected-path collection for removed paths and new cache-backed query paths.
libs/@local/graph/store/src/entity/query.rs Add TypeVersionedUrls/DirectTypeCount, remove descending “Last*” variants, and update sorting behavior.
libs/@local/graph/postgres-store/src/store/postgres/query/table.rs Add EntityEditionCache table/columns and remove legacy view-backed tables/relations.
libs/@local/graph/postgres-store/src/store/postgres/query/statement/select.rs Add compilation test for sorting by cached label/type title; update masking join expectation.
libs/@local/graph/postgres-store/src/store/postgres/query/mod.rs Decode nullable sort keys as Json(Null) sentinel for cursor continuation logic.
libs/@local/graph/postgres-store/src/store/postgres/query/expression/conditional.rs Add Expression::ArrayElement for (<expr>)[idx] SQL emission.
libs/@local/graph/postgres-store/src/store/postgres/query/entity.rs Route entity query paths to cache relations/columns; use array subscript for first label/title.
libs/@local/graph/postgres-store/src/store/postgres/query/compile.rs Support JsonField::ArrayElement compilation and ensure filter parameter typing treats it as text.
libs/@local/graph/postgres-store/src/store/postgres/ontology/entity_type.rs Trigger cache reindex after entity-type schema reindex to avoid stale cached titles/labels.
libs/@local/graph/postgres-store/src/store/postgres/knowledge/entity/query.rs Decode entity type IDs from cached versioned_urls using direct_types prefix length.
libs/@local/graph/postgres-store/src/store/postgres/knowledge/entity/mod.rs Populate cache on write paths; implement cache rebuild during reindex_entity_cache.
libs/@local/graph/postgres-store/src/snapshot/entity/batch.rs Reindex cache after snapshot restore updates that may change label-derived cache entries.
libs/@local/graph/postgres-store/postgres_migrations/V51__entity_edition_cache.sql Production migration: create/backfill cache + indexes; drop legacy aggregate views.
libs/@local/graph/migrations/graph-migrations/v009__entities/up.sql Test migration: add cache table/indexes; remove legacy aggregate views.
libs/@local/graph/migrations/graph-migrations/v009__entities/down.sql Test migration rollback: drop cache table and remove obsolete view drops.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread libs/@local/graph/postgres-store/src/store/postgres/query/table.rs Outdated
Comment thread libs/@local/graph/store/src/entity/query.rs Outdated
@github-actions

Copy link
Copy Markdown
Contributor

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 $$26.5 \mathrm{ms} \pm 219 \mathrm{μs}\left({\color{gray}2.11 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$3.44 \mathrm{ms} \pm 28.2 \mathrm{μs}\left({\color{gray}-4.071 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 1001 $$12.3 \mathrm{ms} \pm 73.6 \mathrm{μs}\left({\color{gray}-4.400 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 3314 $$42.4 \mathrm{ms} \pm 353 \mathrm{μs}\left({\color{lightgreen}-6.451 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$14.4 \mathrm{ms} \pm 117 \mathrm{μs}\left({\color{lightgreen}-7.192 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 1526 $$23.6 \mathrm{ms} \pm 163 \mathrm{μs}\left({\color{lightgreen}-6.747 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 2078 $$27.0 \mathrm{ms} \pm 206 \mathrm{μs}\left({\color{gray}0.799 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.71 \mathrm{ms} \pm 17.8 \mathrm{μs}\left({\color{gray}-4.437 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 1033 $$13.1 \mathrm{ms} \pm 89.0 \mathrm{μs}\left({\color{gray}-2.319 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_medium

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 102 $$3.72 \mathrm{ms} \pm 18.9 \mathrm{μs}\left({\color{gray}-0.835 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.99 \mathrm{ms} \pm 14.1 \mathrm{μs}\left({\color{gray}-0.593 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 51 $$3.29 \mathrm{ms} \pm 16.0 \mathrm{μs}\left({\color{gray}-2.452 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 269 $$5.11 \mathrm{ms} \pm 35.9 \mathrm{μs}\left({\color{gray}-0.273 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$3.54 \mathrm{ms} \pm 15.9 \mathrm{μs}\left({\color{gray}-0.262 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 107 $$4.12 \mathrm{ms} \pm 30.6 \mathrm{μs}\left({\color{gray}1.11 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 133 $$4.34 \mathrm{ms} \pm 28.4 \mathrm{μs}\left({\color{gray}0.663 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.47 \mathrm{ms} \pm 19.8 \mathrm{μs}\left({\color{gray}-0.940 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 63 $$4.07 \mathrm{ms} \pm 26.0 \mathrm{μs}\left({\color{gray}0.273 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_none

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 2 $$2.60 \mathrm{ms} \pm 10.6 \mathrm{μs}\left({\color{gray}-0.127 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.50 \mathrm{ms} \pm 19.3 \mathrm{μs}\left({\color{gray}0.158 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 1 $$2.62 \mathrm{ms} \pm 15.9 \mathrm{μs}\left({\color{gray}0.971 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 8 $$2.92 \mathrm{ms} \pm 13.2 \mathrm{μs}\left({\color{gray}1.89 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.68 \mathrm{ms} \pm 12.5 \mathrm{μs}\left({\color{gray}0.408 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 3 $$2.95 \mathrm{ms} \pm 20.5 \mathrm{μs}\left({\color{gray}2.93 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_small

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 52 $$3.00 \mathrm{ms} \pm 14.5 \mathrm{μs}\left({\color{gray}-0.695 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.74 \mathrm{ms} \pm 11.5 \mathrm{μs}\left({\color{gray}-0.491 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 25 $$2.97 \mathrm{ms} \pm 13.8 \mathrm{μs}\left({\color{gray}-0.405 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 94 $$3.38 \mathrm{ms} \pm 18.8 \mathrm{μs}\left({\color{gray}0.385 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$2.96 \mathrm{ms} \pm 16.1 \mathrm{μs}\left({\color{gray}-0.931 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 26 $$3.25 \mathrm{ms} \pm 18.1 \mathrm{μs}\left({\color{gray}-0.652 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 66 $$3.28 \mathrm{ms} \pm 17.6 \mathrm{μs}\left({\color{gray}-0.757 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.95 \mathrm{ms} \pm 15.4 \mathrm{μs}\left({\color{gray}-0.589 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 29 $$3.27 \mathrm{ms} \pm 17.4 \mathrm{μs}\left({\color{gray}-0.901 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_complete

Function Value Mean Flame graphs
entity_by_id;one_depth 1 entities $$56.9 \mathrm{ms} \pm 314 \mathrm{μs}\left({\color{gray}1.63 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 10 entities $$48.7 \mathrm{ms} \pm 223 \mathrm{μs}\left({\color{lightgreen}-6.692 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 25 entities $$51.7 \mathrm{ms} \pm 361 \mathrm{μs}\left({\color{gray}2.13 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 5 entities $$46.2 \mathrm{ms} \pm 201 \mathrm{μs}\left({\color{lightgreen}-19.934 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 50 entities $$62.6 \mathrm{ms} \pm 336 \mathrm{μs}\left({\color{gray}-0.923 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 1 entities $$64.1 \mathrm{ms} \pm 366 \mathrm{μs}\left({\color{gray}2.30 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 10 entities $$56.5 \mathrm{ms} \pm 314 \mathrm{μs}\left({\color{gray}-0.605 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 25 entities $$106 \mathrm{ms} \pm 589 \mathrm{μs}\left({\color{gray}0.524 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 5 entities $$48.4 \mathrm{ms} \pm 285 \mathrm{μs}\left({\color{gray}2.78 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 50 entities $$294 \mathrm{ms} \pm 1.04 \mathrm{ms}\left({\color{gray}-1.373 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 1 entities $$21.8 \mathrm{ms} \pm 97.0 \mathrm{μs}\left({\color{gray}0.049 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 10 entities $$23.0 \mathrm{ms} \pm 89.9 \mathrm{μs}\left({\color{red}13.3 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 25 entities $$22.7 \mathrm{ms} \pm 115 \mathrm{μs}\left({\color{red}11.9 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 5 entities $$21.8 \mathrm{ms} \pm 117 \mathrm{μs}\left({\color{red}11.7 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 50 entities $$27.4 \mathrm{ms} \pm 162 \mathrm{μs}\left({\color{red}7.17 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_linkless

Function Value Mean Flame graphs
entity_by_id 1 entities $$21.6 \mathrm{ms} \pm 110 \mathrm{μs}\left({\color{red}12.7 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$21.6 \mathrm{ms} \pm 98.0 \mathrm{μs}\left({\color{red}11.1 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 100 entities $$21.6 \mathrm{ms} \pm 99.2 \mathrm{μs}\left({\color{red}11.4 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1000 entities $$21.6 \mathrm{ms} \pm 97.2 \mathrm{μs}\left({\color{red}6.62 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10000 entities $$23.7 \mathrm{ms} \pm 177 \mathrm{μs}\left({\color{lightgreen}-10.342 \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 $$24.5 \mathrm{ms} \pm 109 \mathrm{μs}\left({\color{lightgreen}-28.138 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1 $$24.6 \mathrm{ms} \pm 119 \mathrm{μs}\left({\color{lightgreen}-26.772 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1 $$24.5 \mathrm{ms} \pm 139 \mathrm{μs}\left({\color{lightgreen}-28.819 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1 $$24.3 \mathrm{ms} \pm 104 \mathrm{μs}\left({\color{lightgreen}-29.214 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/page/v/2 $$24.4 \mathrm{ms} \pm 152 \mathrm{μs}\left({\color{lightgreen}-28.236 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1 $$24.7 \mathrm{ms} \pm 123 \mathrm{μs}\left({\color{lightgreen}-25.697 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/playlist/v/1 $$26.1 \mathrm{ms} \pm 116 \mathrm{μs}\left({\color{lightgreen}-23.856 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1 $$26.2 \mathrm{ms} \pm 128 \mathrm{μs}\left({\color{lightgreen}-24.958 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1 $$24.8 \mathrm{ms} \pm 133 \mathrm{μs}\left({\color{lightgreen}-27.975 \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.56 \mathrm{ms} \pm 55.5 \mathrm{μs}\left({\color{gray}1.55 \mathrm{\%}}\right) $$ Flame Graph

representative_read_multiple_entities

Function Value Mean Flame graphs
entity_by_property traversal_paths=0 0 $$60.4 \mathrm{ms} \pm 474 \mathrm{μs}\left({\color{lightgreen}-34.140 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=255 1,resolve_depths=inherit:1;values:255;properties:255;links:127;link_dests:126;type:true $$113 \mathrm{ms} \pm 660 \mathrm{μs}\left({\color{lightgreen}-21.873 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:0;link_dests:0;type:false $$67.3 \mathrm{ms} \pm 563 \mathrm{μs}\left({\color{lightgreen}-31.155 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:1;link_dests:0;type:true $$77.4 \mathrm{ms} \pm 540 \mathrm{μs}\left({\color{lightgreen}-29.361 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:2;links:1;link_dests:0;type:true $$86.4 \mathrm{ms} \pm 390 \mathrm{μs}\left({\color{lightgreen}-25.548 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:2;properties:2;links:1;link_dests:0;type:true $$91.4 \mathrm{ms} \pm 420 \mathrm{μs}\left({\color{lightgreen}-26.094 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=0 0 $$80.4 \mathrm{ms} \pm 343 \mathrm{μs}\left({\color{lightgreen}-21.190 \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 $$109 \mathrm{ms} \pm 445 \mathrm{μs}\left({\color{lightgreen}-17.354 \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 $$87.7 \mathrm{ms} \pm 484 \mathrm{μs}\left({\color{lightgreen}-20.044 \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 $$96.6 \mathrm{ms} \pm 394 \mathrm{μs}\left({\color{lightgreen}-18.625 \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 $$98.4 \mathrm{ms} \pm 396 \mathrm{μs}\left({\color{lightgreen}-18.461 \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 $$98.8 \mathrm{ms} \pm 561 \mathrm{μs}\left({\color{lightgreen}-18.172 \mathrm{\%}}\right) $$

scenarios

Function Value Mean Flame graphs
full_test query-limited $$150 \mathrm{ms} \pm 714 \mathrm{μs}\left({\color{gray}-3.771 \mathrm{\%}}\right) $$ Flame Graph
full_test query-unlimited $$157 \mathrm{ms} \pm 656 \mathrm{μs}\left({\color{red}5.67 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-limited $$44.6 \mathrm{ms} \pm 189 \mathrm{μs}\left({\color{red}8.97 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-unlimited $$550 \mathrm{ms} \pm 1.05 \mathrm{ms}\left({\color{lightgreen}-5.022 \mathrm{\%}}\right) $$ Flame Graph

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

Labels

area/libs Relates to first-party libraries/crates/packages (area) area/tests New or updated tests type/eng > backend Owned by the @backend team

Development

Successfully merging this pull request may close these issues.

3 participants