projects
/
odoo
/
odoo.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
726725a
)
[IMP] models.py: _auto_init: accelerate row existance check
author
Christophe Simonis
<chs@odoo.com>
Tue, 12 Aug 2014 16:38:55 +0000
(18:38 +0200)
committer
Christophe Simonis
<chs@odoo.com>
Tue, 12 Aug 2014 16:38:55 +0000
(18:38 +0200)
Using `COUNT(1)` on big table can be slow. Use `min(id)` which use
pkey index to have a quicker response
openerp/models.py
patch
|
blob
|
history
diff --git
a/openerp/models.py
b/openerp/models.py
index
e8b531a
..
bbcee1f
100644
(file)
--- a/
openerp/models.py
+++ b/
openerp/models.py
@@
-2474,8
+2474,8
@@
class BaseModel(object):
self._create_table(cr)
has_rows = False
else:
- cr.execute('SELECT COUNT(1) FROM "%s"' % (self._table,))
- has_rows = cr.fetchone()[0]
+ cr.execute('SELECT min(id) FROM "%s"' % (self._table,))
+ has_rows = cr.fetchone()[0] is not None
cr.commit()
if self._parent_store: