Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

H-3285, H-3286: Optionally return set of distinct values for entity (type) queries #5029

Conversation

TimDiekmann
Copy link
Member

🌟 What is the purpose of this PR?

When requested, a set ( count) of all possible values should be returned independent of pagination.

🔍 What does this change?

Allow specifying a set of distinct values ( count) for:

  • web (only entities and owned types)
  • createdById (only entities, we currently don't store the initial creator of a type)
  • editionCreatedById (corresponds to updatedById)
  • types (only entities)

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

@TimDiekmann TimDiekmann self-assigned this Sep 9, 2024
@github-actions github-actions bot added area/apps > hash* Affects HASH (a `hash-*` app) type/eng > backend Owned by the @backend team area/apps area/apps > hash-graph labels Sep 9, 2024
@github-actions github-actions bot added area/tests New or updated tests area/tests > integration New or updated integration tests labels Sep 9, 2024
Copy link
Contributor

github-actions bot commented Sep 9, 2024

Benchmark results

@rust/graph-benches – Integrations

scaling_read_entity_complete_one_depth

Function Value Mean Flame graphs
entity_by_id 10 entities $$51.3 \mathrm{ms} \pm 191 \mathrm{μs}\left({\color{red}13.3 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 50 entities $$1.54 \mathrm{s} \pm 3.21 \mathrm{ms}\left({\color{gray}-0.314 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$19.8 \mathrm{ms} \pm 110 \mathrm{μs}\left({\color{gray}0.422 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 25 entities $$73.9 \mathrm{ms} \pm 433 \mathrm{μs}\left({\color{gray}4.54 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 5 entities $$24.9 \mathrm{ms} \pm 145 \mathrm{μs}\left({\color{gray}1.67 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_complete_zero_depth

Function Value Mean Flame graphs
entity_by_id 10 entities $$2.03 \mathrm{ms} \pm 9.06 \mathrm{μs}\left({\color{gray}-1.753 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 50 entities $$3.86 \mathrm{ms} \pm 15.9 \mathrm{μs}\left({\color{gray}-0.640 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$1.86 \mathrm{ms} \pm 13.2 \mathrm{μs}\left({\color{gray}0.499 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 25 entities $$2.55 \mathrm{ms} \pm 13.6 \mathrm{μs}\left({\color{gray}-3.217 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 5 entities $$1.92 \mathrm{ms} \pm 15.0 \mathrm{μs}\left({\color{gray}-0.043 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_linkless

Function Value Mean Flame graphs
entity_by_id 10 entities $$1.85 \mathrm{ms} \pm 8.87 \mathrm{μs}\left({\color{gray}0.248 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 100 entities $$2.01 \mathrm{ms} \pm 9.99 \mathrm{μs}\left({\color{gray}0.854 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1000 entities $$2.71 \mathrm{ms} \pm 11.5 \mathrm{μs}\left({\color{lightgreen}-6.872 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$1.84 \mathrm{ms} \pm 8.70 \mathrm{μs}\left({\color{gray}1.42 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10000 entities $$12.9 \mathrm{ms} \pm 147 \mathrm{μs}\left({\color{gray}0.621 \mathrm{\%}}\right) $$ Flame Graph

representative_read_entity_type

Function Value Mean Flame graphs
get_entity_type_by_id Account ID: d4e16033-c281-4cde-aa35-9085bf2e7579 $$1.40 \mathrm{ms} \pm 5.53 \mathrm{μs}\left({\color{gray}0.192 \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/building/v/1 $$15.7 \mathrm{ms} \pm 194 \mathrm{μs}\left({\color{gray}-3.633 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/page/v/2 $$16.0 \mathrm{ms} \pm 186 \mathrm{μs}\left({\color{gray}-2.914 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1 $$15.6 \mathrm{ms} \pm 177 \mathrm{μs}\left({\color{gray}0.511 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/block/v/1 $$15.7 \mathrm{ms} \pm 151 \mathrm{μs}\left({\color{gray}1.97 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1 $$15.5 \mathrm{ms} \pm 169 \mathrm{μs}\left({\color{lightgreen}-6.933 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/playlist/v/1 $$16.5 \mathrm{ms} \pm 205 \mathrm{μs}\left({\color{red}5.32 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1 $$15.9 \mathrm{ms} \pm 219 \mathrm{μs}\left({\color{gray}-0.593 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1 $$15.2 \mathrm{ms} \pm 144 \mathrm{μs}\left({\color{gray}-4.357 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1 $$15.4 \mathrm{ms} \pm 168 \mathrm{μs}\left({\color{gray}0.284 \mathrm{\%}}\right) $$ Flame Graph

representative_read_multiple_entities

Function Value Mean Flame graphs
link_by_source_by_property depths: DT=2, PT=2, ET=2, E=2 $$95.4 \mathrm{ms} \pm 565 \mathrm{μs}\left({\color{gray}2.88 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=0, E=2 $$75.1 \mathrm{ms} \pm 691 \mathrm{μs}\left({\color{gray}0.961 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=0, E=0 $$38.4 \mathrm{ms} \pm 220 \mathrm{μs}\left({\color{gray}-1.465 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=2, E=2 $$85.1 \mathrm{ms} \pm 621 \mathrm{μs}\left({\color{gray}-0.493 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=2, ET=2, E=2 $$90.8 \mathrm{ms} \pm 577 \mathrm{μs}\left({\color{gray}1.88 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=255, PT=255, ET=255, E=255 $$103 \mathrm{ms} \pm 675 \mathrm{μs}\left({\color{gray}2.88 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=2, PT=2, ET=2, E=2 $$54.0 \mathrm{ms} \pm 255 \mathrm{μs}\left({\color{gray}-2.254 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=0, E=2 $$39.0 \mathrm{ms} \pm 189 \mathrm{μs}\left({\color{gray}-3.986 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=0, E=0 $$35.3 \mathrm{ms} \pm 259 \mathrm{μs}\left({\color{gray}-3.586 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=2, E=2 $$45.7 \mathrm{ms} \pm 244 \mathrm{μs}\left({\color{gray}-3.447 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=2, ET=2, E=2 $$50.0 \mathrm{ms} \pm 270 \mathrm{μs}\left({\color{gray}-2.058 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=255, PT=255, ET=255, E=255 $$62.8 \mathrm{ms} \pm 375 \mathrm{μs}\left({\color{gray}-1.097 \mathrm{\%}}\right) $$ Flame Graph

@TimDiekmann TimDiekmann added this pull request to the merge queue Sep 9, 2024
Merged via the queue into main with commit ed39631 Sep 9, 2024
84 checks passed
@TimDiekmann TimDiekmann deleted the t/h-3285-optionally-return-a-set-of-distinct-values-when-querying branch September 9, 2024 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/apps > hash* Affects HASH (a `hash-*` app) area/apps > hash-graph area/apps area/tests > integration New or updated integration tests area/tests New or updated tests type/eng > backend Owned by the @backend team
Development

Successfully merging this pull request may close these issues.

2 participants