Commit 5f7a9142 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Optimize SQL query to take advantage of indexes in getLastTID.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2322 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 5b48a7dd
...@@ -250,7 +250,8 @@ class MySQLDatabaseManager(DatabaseManager): ...@@ -250,7 +250,8 @@ class MySQLDatabaseManager(DatabaseManager):
# is worth. # is worth.
q = self.query q = self.query
self.begin() self.begin()
ltid = q("""SELECT MAX(tid) FROM trans""")[0][0] ltid = q("SELECT MAX(value) FROM (SELECT MAX(tid) AS value FROM trans "
"GROUP BY partition) AS foo")[0][0]
if all: if all:
tmp_ltid = q("""SELECT MAX(tid) FROM ttrans""")[0][0] tmp_ltid = q("""SELECT MAX(tid) FROM ttrans""")[0][0]
if ltid is None or (tmp_ltid is not None and ltid < tmp_ltid): if ltid is None or (tmp_ltid is not None and ltid < tmp_ltid):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment