fix: query performance degration caused by date normalization

This commit is contained in:
Junyi Du
2022-12-13 21:40:43 +08:00
committed by Tienson Qin
parent 6237399a0c
commit dbf13c87d9
4 changed files with 17 additions and 10 deletions

View File

@@ -56,9 +56,13 @@ and handles unexpected failure."
(tf/unparse date/custom-formatter))))
(defn normalize-block
"Normalizes supported formats such as dates and percentages."
([block]
(->> [normalize-as-percentage normalize-as-date identity]
"Normalizes supported formats such as dates and percentages.
Be careful, this function may harm query sort performance!
- nlp-date? - Enable NLP parsing on date items.
Requires heavy computation (see `normalize-as-date` for details)"
([block nlp-date?]
(->> [normalize-as-percentage (when nlp-date? normalize-as-date) identity]
(remove nil?)
(map #(% (if (set? block) (first block) block)))
(remove nil?)
(first))))