mirror of
https://github.com/chatmail/core.git
synced 2026-05-18 22:36:29 +03:00
Optimize delete_expired_imap_messages()
For me this reduced query time from 0.3 s to 0.05 s.
This commit is contained in:
@@ -1,5 +1,11 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
### Changes
|
||||||
|
- optimize `delete_expired_imap_messages()` #3047
|
||||||
|
|
||||||
|
|
||||||
## 1.74.0
|
## 1.74.0
|
||||||
|
|
||||||
### Fixes
|
### Fixes
|
||||||
|
|||||||
@@ -451,12 +451,11 @@ pub(crate) async fn delete_expired_imap_messages(context: &Context) -> Result<()
|
|||||||
.execute(
|
.execute(
|
||||||
"UPDATE imap
|
"UPDATE imap
|
||||||
SET target=''
|
SET target=''
|
||||||
WHERE EXISTS (
|
WHERE rfc724_mid IN (
|
||||||
SELECT * FROM msgs
|
SELECT rfc724_mid FROM msgs
|
||||||
WHERE rfc724_mid=imap.rfc724_mid
|
WHERE ((download_state = 0 AND timestamp < ?) OR
|
||||||
AND ((download_state = 0 AND timestamp < ?) OR
|
(download_state != 0 AND timestamp < ?) OR
|
||||||
(download_state != 0 AND timestamp < ?) OR
|
(ephemeral_timestamp != 0 AND ephemeral_timestamp <= ?))
|
||||||
(ephemeral_timestamp != 0 AND ephemeral_timestamp <= ?))
|
|
||||||
)",
|
)",
|
||||||
paramsv![threshold_timestamp, threshold_timestamp_extended, now],
|
paramsv![threshold_timestamp, threshold_timestamp_extended, now],
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user