Skip to content

Commit

Permalink
fix: speed up get deleted. remove unnecessary subquery
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksandr Sorokin committed Nov 7, 2023
1 parent c6ed0c3 commit d27bad2
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions reversion/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,11 @@ def get_deleted(self, model, model_db=None):
# conditional expressions are being supported since django 3.0
# DISTINCT ON works only for Postgres DB
if connection.vendor == "postgresql" and django.VERSION >= (3, 0):
subquery = (
return (
self.get_for_model(model, model_db=model_db)
.filter(~models.Exists(model_qs))
.order_by("object_id", "-pk")
.distinct("object_id")
.values("pk")
)
else:
subquery = (
Expand Down

0 comments on commit d27bad2

Please sign in to comment.