Skip to content

Commit

Permalink
Use max(x) instead of ORDER BY x DESC LIMIT 1
Browse files Browse the repository at this point in the history
Doesn't use non-standard syntax, clearer intent, reportedly faster
  • Loading branch information
tsudoko committed Jan 4, 2020
1 parent e8850f2 commit 3b8fe9e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ankisyncd/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def dir(self):
return self._dir

def lastUsn(self):
return self.db.scalar("SELECT usn FROM media ORDER BY usn DESC LIMIT 1") or 0
return self.db.scalar("SELECT max(usn) FROM media") or 0

def mediaCount(self):
return self.db.scalar("SELECT count() FROM media WHERE csum IS NOT NULL")
Expand Down

0 comments on commit 3b8fe9e

Please sign in to comment.