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-3723: Add link table indices #5771

Conversation

TimDiekmann
Copy link
Member

🌟 What is the purpose of this PR?

I further tested out on adding more indices. A direct improvement gave the link-entity indices (uni-directional). All other indices did not show a noticeable change or even decreased performance. I don’t think there is any point in poking around in indices even more if we don’t have more benchmark coverage in place or a query in mind in particular which is slow.

🔍 What does this change?

Add the two link-indices

Copy link
Contributor

github-actions bot commented Dec 2, 2024

Benchmark results

@rust/hash-graph-benches – Integrations

representative_read_entity

Function Value Mean Flame graphs
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/playlist/v/1 $$16.6 \mathrm{ms} \pm 139 \mathrm{μs}\left({\color{gray}-3.431 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1 $$15.7 \mathrm{ms} \pm 174 \mathrm{μs}\left({\color{gray}-4.382 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/page/v/2 $$16.3 \mathrm{ms} \pm 174 \mathrm{μs}\left({\color{lightgreen}-5.369 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1 $$16.7 \mathrm{ms} \pm 146 \mathrm{μs}\left({\color{gray}-2.865 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1 $$16.5 \mathrm{ms} \pm 165 \mathrm{μs}\left({\color{gray}-0.463 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1 $$16.9 \mathrm{ms} \pm 177 \mathrm{μs}\left({\color{red}5.03 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1 $$17.3 \mathrm{ms} \pm 183 \mathrm{μs}\left({\color{red}5.36 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/block/v/1 $$15.5 \mathrm{ms} \pm 162 \mathrm{μs}\left({\color{gray}-4.161 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1 $$16.1 \mathrm{ms} \pm 162 \mathrm{μs}\left({\color{gray}1.84 \mathrm{\%}}\right) $$ Flame Graph

representative_read_multiple_entities

Function Value Mean Flame graphs
entity_by_property depths: DT=255, PT=255, ET=255, E=255 $$68.4 \mathrm{ms} \pm 405 \mathrm{μs}\left({\color{gray}-2.359 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=0, E=0 $$39.1 \mathrm{ms} \pm 372 \mathrm{μs}\left({\color{gray}-2.672 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=2, PT=2, ET=2, E=2 $$57.2 \mathrm{ms} \pm 305 \mathrm{μs}\left({\color{gray}-3.979 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=0, E=2 $$43.8 \mathrm{ms} \pm 255 \mathrm{μs}\left({\color{gray}-2.289 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=2, E=2 $$48.7 \mathrm{ms} \pm 358 \mathrm{μs}\left({\color{gray}-3.337 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=2, ET=2, E=2 $$53.6 \mathrm{ms} \pm 260 \mathrm{μs}\left({\color{gray}-4.283 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=255, PT=255, ET=255, E=255 $$109 \mathrm{ms} \pm 496 \mathrm{μs}\left({\color{gray}0.058 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=0, E=0 $$43.3 \mathrm{ms} \pm 315 \mathrm{μs}\left({\color{gray}-1.634 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=2, PT=2, ET=2, E=2 $$99.9 \mathrm{ms} \pm 662 \mathrm{μs}\left({\color{gray}0.369 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=0, E=2 $$81.1 \mathrm{ms} \pm 548 \mathrm{μs}\left({\color{gray}-0.479 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=2, E=2 $$90.5 \mathrm{ms} \pm 439 \mathrm{μs}\left({\color{gray}0.556 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=2, ET=2, E=2 $$96.4 \mathrm{ms} \pm 443 \mathrm{μs}\left({\color{gray}1.65 \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.38 \mathrm{ms} \pm 2.91 \mathrm{μs}\left({\color{gray}-0.083 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_complete_one_depth

Function Value Mean Flame graphs
entity_by_id 50 entities $$5.25 \mathrm{s} \pm 838 \mathrm{ms}\left({\color{red}1912 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 5 entities $$27.4 \mathrm{ms} \pm 169 \mathrm{μs}\left({\color{red}8.38 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$20.4 \mathrm{ms} \pm 91.6 \mathrm{μs}\left({\color{gray}1.21 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$57.1 \mathrm{ms} \pm 381 \mathrm{μs}\left({\color{red}82.3 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 25 entities $$178 \mathrm{ms} \pm 770 \mathrm{μs}\left({\color{red}149 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_linkless

Function Value Mean Flame graphs
entity_by_id 1 entities $$1.96 \mathrm{ms} \pm 7.23 \mathrm{μs}\left({\color{gray}4.29 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 100 entities $$2.13 \mathrm{ms} \pm 8.64 \mathrm{μs}\left({\color{gray}3.52 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$1.95 \mathrm{ms} \pm 5.73 \mathrm{μs}\left({\color{gray}-0.238 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1000 entities $$2.86 \mathrm{ms} \pm 13.3 \mathrm{μs}\left({\color{gray}-4.389 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10000 entities $$13.7 \mathrm{ms} \pm 59.3 \mathrm{μs}\left({\color{gray}-0.640 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_complete_zero_depth

Function Value Mean Flame graphs
entity_by_id 50 entities $$5.07 \mathrm{ms} \pm 17.9 \mathrm{μs}\left({\color{red}18.1 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 5 entities $$1.97 \mathrm{ms} \pm 13.9 \mathrm{μs}\left({\color{gray}3.43 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$1.93 \mathrm{ms} \pm 9.55 \mathrm{μs}\left({\color{gray}2.30 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$2.14 \mathrm{ms} \pm 13.7 \mathrm{μs}\left({\color{gray}1.87 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 25 entities $$2.80 \mathrm{ms} \pm 16.7 \mathrm{μs}\left({\color{lightgreen}-16.501 \mathrm{\%}}\right) $$ Flame Graph

@TimDiekmann TimDiekmann added this pull request to the merge queue Dec 2, 2024
Merged via the queue into main with commit c3030df Dec 2, 2024
88 checks passed
@TimDiekmann TimDiekmann deleted the t/h-3723-create-indices-to-postgres-which-are-directly-used-in branch December 2, 2024 21:46
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) type/eng > backend Owned by the @backend team
Development

Successfully merging this pull request may close these issues.

2 participants