Refine index definition

- Set low and high cardinality to index usage
- Use Range usage for numerical expression instead of Equality
This commit is contained in:
Cédric Krier
2024-07-27 18:36:14 +02:00
parent 234daa0f99
commit a2dfc4455b
64 changed files with 171 additions and 149 deletions
+10 -10
View File
@@ -80,23 +80,23 @@ class Line(ModelSQL, ModelView):
cls._sql_indexes.update({
Index(
t,
(t.date, Index.Equality()),
(t.company, Index.Equality()),
(t.employee, Index.Equality())),
(t.date, Index.Range()),
(t.company, Index.Range()),
(t.employee, Index.Range())),
Index(
t,
(t.date, Index.Range()),
(t.employee, Index.Equality())),
(t.employee, Index.Range())),
Index(
t,
(Extract('YEAR', t.date), Index.Equality()),
(Extract('WEEK', t.date), Index.Equality()),
(t.employee, Index.Equality())),
(Extract('YEAR', t.date), Index.Range()),
(Extract('WEEK', t.date), Index.Range()),
(t.employee, Index.Range())),
Index(
t,
(Extract('YEAR', t.date), Index.Equality()),
(Extract('MONTH', t.date), Index.Equality()),
(t.employee, Index.Equality())),
(Extract('YEAR', t.date), Index.Range()),
(Extract('MONTH', t.date), Index.Range()),
(t.employee, Index.Range())),
})
@staticmethod