Skip to content

Commit

Permalink
Merge pull request #951 from caullla/master
Browse files Browse the repository at this point in the history
fix: speed up get deleted. remove unnecessary subquery
  • Loading branch information
etianen authored Nov 7, 2023
2 parents c6ed0c3 + d27bad2 commit c6321d6
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 c6321d6

Please sign in to comment.