Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: Avoid coalesce for between filters (backport #26531) #26533

Merged
merged 1 commit into from
May 22, 2024

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented May 22, 2024

Between operator never needs to check for null.

Explanation: Consider SQL -> COLUMN between X and Y

Actual computation:

    for row in rows:
    if Y > row.COLUMN > X:
        yield row

Since Y and X can't be null, null value in column will never match this filter, so coalesce is extra cost that prevents index usage.

Same logic applies for DATETIME_FIELD > X, as X is not null, DATETIME_FIELD will never match the filter if it's null, so no need check for ifnull.


This is an automatic backport of pull request #26531 done by Mergify.

- Avoid on `between` + date
- Avoid on timestamp fields
- Avoid on `>` and `>=` comparisons

(cherry picked from commit 005e74b)
@mergify mergify bot assigned ankush May 22, 2024
@ankush ankush enabled auto-merge (squash) May 22, 2024 09:36
@ankush ankush merged commit 446780c into version-14-hotfix May 22, 2024
9 of 10 checks passed
@ankush ankush deleted the mergify/bp/version-14-hotfix/pr-26531 branch May 22, 2024 09:51
frappe-pr-bot pushed a commit that referenced this pull request May 28, 2024
# [14.76.0](v14.75.0...v14.76.0) (2024-05-28)

### Bug Fixes

* Appropriate variable name, avoid redefining parameter ([83cf2df](83cf2df))
* reload before saving on reconnect ([#26534](#26534)) ([#26536](#26536)) ([b2d17c1](b2d17c1))
* Use true stderr for dumping trace ([#26524](#26524)) ([#26526](#26526)) ([30676fb](30676fb))

### Features

* Add `on_add_row` event for grid in Dialog ([8db7fcd](8db7fcd))

### Performance Improvements

* Avoid coalesce for `between` filters ([#26531](#26531)) ([#26533](#26533)) ([446780c](446780c))
@frappe-pr-bot
Copy link
Collaborator

🎉 This PR is included in version 14.76.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants