ash-project / ash-project/ash

Optimize calculation/aggregate/relationship merging/reuse in calculation dependencies

Open
#1,282 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Elixir
Stars
2.5k
Forks
426
Avg merge
23h 26m
Merged PRs (30d)
46

Description

We had to make a recent fix that reduces drastically the amount of cases where calculations, relationships and aggregates required by calculations in their `load/3` callback can be reused in the case that they are being loaded. This is because there is an important semantic difference: calculation dependencies should not have authorization rules applied to them.

However, there should be some analysis that can be applied to determine the ability to share, for example:

- if the calculation is being run with `calculate/3`, we can reuse it.
- If the calculation doesn't reference any aggregates or relationships, we can reuse it (traversing any nested calculations)
- If the calculation references relationships and those relationships have no authorizers

These are some naive optimizations that could be applied.

Contributor guide

Open the contributing guide

Research direction

Start by tracing calculation dependency loading around the `load/3` and `calculate/3` callbacks, then inspect how authorization rules affect calculations, relationships, and aggregates. Done means reuse is safely identified for the stated cases without applying authorization rules where calculation dependencies must avoid them.

Written by the indexing model from the issue text.

Assessment

Tech stack
elixir
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.