Skip to content

feat: provide a mechanism to temporarily disable aggregation #770

@eelkevdbos

Description

@eelkevdbos

For an import job, I would like to disable the aggregation temporarily to improve performance and reduce the risk of deadlocks.

A context manager seems like a suitable interface for such a feature, like so:

with aggregations_disabled():
  # trigger model inserts / updates without triggering aggregation
  ...

A quick and dirty way would be to add (actually, prepend) a line to construct_aggregate_queries like so:

def construct_aggregate_queries(self):
  if self.aggregation_disabled:
    return
  ...

The context manager then implemented like:

@contextmanager
def aggregations_disabled():
  manager.aggregation_disabled = True
  yield
  manager.aggregation_disabled = False

@kvesteri, do you have any thoughts on feasibility of this approach? I'm happy to submit a PR for the feature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions