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-3612: Properly detect tables with different inheritance depths #5770

Conversation

TimDiekmann
Copy link
Member

🌟 What is the purpose of this PR?

If the same table was joined with different parameters it failed because the alias was not changed even though it should have.

🔍 What does this change?

If no equal tables are detected, the reference tables are checked if the variant is matching. If so, the alias is increased instead which leads to the desired behavior.

⚠️ Known issues

Technically, the inheritanceDepth should probably be stored as a parameter on the Relation instead but not all relations has an inheritanceDepth. Changing this would be a bigger change.

@TimDiekmann TimDiekmann self-assigned this Dec 2, 2024
@github-actions github-actions bot added area/libs Relates to first-party libraries/crates/packages (area) type/eng > backend Owned by the @backend team labels Dec 2, 2024
@TimDiekmann TimDiekmann added this pull request to the merge queue Dec 2, 2024
Merged via the queue into main with commit ebd1c2a Dec 2, 2024
86 checks passed
@TimDiekmann TimDiekmann deleted the t/h-3612-fix-entity_is_of_type-reference-table-specified-more-than branch December 2, 2024 16:10
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/book/v/1 $$17.2 \mathrm{ms} \pm 211 \mathrm{μs}\left({\color{red}5.39 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/block/v/1 $$16.7 \mathrm{ms} \pm 241 \mathrm{μs}\left({\color{gray}1.66 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1 $$15.8 \mathrm{ms} \pm 211 \mathrm{μs}\left({\color{gray}-0.681 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/playlist/v/1 $$17.0 \mathrm{ms} \pm 198 \mathrm{μs}\left({\color{gray}-0.712 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1 $$15.4 \mathrm{ms} \pm 179 \mathrm{μs}\left({\color{lightgreen}-7.194 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1 $$15.5 \mathrm{ms} \pm 199 \mathrm{μs}\left({\color{lightgreen}-7.012 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/page/v/2 $$17.4 \mathrm{ms} \pm 214 \mathrm{μs}\left({\color{gray}-0.425 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1 $$16.4 \mathrm{ms} \pm 231 \mathrm{μs}\left({\color{lightgreen}-5.949 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1 $$16.9 \mathrm{ms} \pm 228 \mathrm{μs}\left({\color{red}5.04 \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 $$69.6 \mathrm{ms} \pm 454 \mathrm{μs}\left({\color{gray}-0.095 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=0, E=0 $$40.3 \mathrm{ms} \pm 203 \mathrm{μs}\left({\color{gray}-1.447 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=2, PT=2, ET=2, E=2 $$59.3 \mathrm{ms} \pm 310 \mathrm{μs}\left({\color{gray}1.03 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=0, E=2 $$44.6 \mathrm{ms} \pm 268 \mathrm{μs}\left({\color{gray}0.553 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=2, E=2 $$51.0 \mathrm{ms} \pm 329 \mathrm{μs}\left({\color{gray}1.63 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=2, ET=2, E=2 $$54.6 \mathrm{ms} \pm 295 \mathrm{μs}\left({\color{gray}-0.119 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=255, PT=255, ET=255, E=255 $$109 \mathrm{ms} \pm 447 \mathrm{μs}\left({\color{gray}0.787 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=0, E=0 $$42.8 \mathrm{ms} \pm 163 \mathrm{μs}\left({\color{gray}0.225 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=2, PT=2, ET=2, E=2 $$98.8 \mathrm{ms} \pm 479 \mathrm{μs}\left({\color{gray}-0.859 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=0, E=2 $$81.4 \mathrm{ms} \pm 472 \mathrm{μs}\left({\color{gray}0.736 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=2, E=2 $$89.5 \mathrm{ms} \pm 302 \mathrm{μs}\left({\color{gray}-1.973 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=2, ET=2, E=2 $$94.5 \mathrm{ms} \pm 532 \mathrm{μs}\left({\color{gray}-0.807 \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.39 \mathrm{ms} \pm 6.13 \mathrm{μs}\left({\color{gray}0.739 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_complete_one_depth

Function Value Mean Flame graphs
entity_by_id 50 entities $$551 \mathrm{ms} \pm 4.06 \mathrm{ms}\left({\color{red}113 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 5 entities $$25.2 \mathrm{ms} \pm 121 \mathrm{μs}\left({\color{gray}0.391 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$20.2 \mathrm{ms} \pm 141 \mathrm{μs}\left({\color{gray}0.217 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$48.3 \mathrm{ms} \pm 1.98 \mathrm{ms}\left({\color{red}56.9 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 25 entities $$72.1 \mathrm{ms} \pm 420 \mathrm{μs}\left({\color{gray}0.389 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_linkless

Function Value Mean Flame graphs
entity_by_id 1 entities $$1.84 \mathrm{ms} \pm 4.77 \mathrm{μs}\left({\color{gray}-1.748 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 100 entities $$1.97 \mathrm{ms} \pm 7.79 \mathrm{μs}\left({\color{gray}-3.433 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$1.89 \mathrm{ms} \pm 5.75 \mathrm{μs}\left({\color{gray}-0.833 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1000 entities $$2.81 \mathrm{ms} \pm 14.6 \mathrm{μs}\left({\color{gray}-3.754 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10000 entities $$13.7 \mathrm{ms} \pm 84.0 \mathrm{μs}\left({\color{gray}0.336 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_complete_zero_depth

Function Value Mean Flame graphs
entity_by_id 50 entities $$5.49 \mathrm{ms} \pm 81.5 \mathrm{μs}\left({\color{red}29.1 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 5 entities $$1.89 \mathrm{ms} \pm 11.3 \mathrm{μs}\left({\color{gray}0.047 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$1.86 \mathrm{ms} \pm 14.3 \mathrm{μs}\left({\color{gray}0.138 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$2.12 \mathrm{ms} \pm 8.40 \mathrm{μs}\left({\color{red}6.10 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 25 entities $$3.34 \mathrm{ms} \pm 19.5 \mathrm{μs}\left({\color{gray}1.25 \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) type/eng > backend Owned by the @backend team
Development

Successfully merging this pull request may close these issues.

2 participants