mirror of
https://github.com/chatmail/core.git
synced 2026-05-22 16:26:31 +03:00
Sort global message search result only by ID
It reduces the time by ~20% according to `search_msgs` benchmark. Sorting by IDs is sufficient for global search as IDs increase in the order of message reception.
This commit is contained in:
@@ -500,6 +500,11 @@ impl Context {
|
|||||||
.collect::<sqlx::Result<Vec<MsgId>>>()
|
.collect::<sqlx::Result<Vec<MsgId>>>()
|
||||||
.await?
|
.await?
|
||||||
} else {
|
} else {
|
||||||
|
// For performance reasons results are sorted only by `id`, that is in the order of
|
||||||
|
// message reception.
|
||||||
|
//
|
||||||
|
// Unlike chat view, sorting by `timestamp` is not necessary but slows down the query by
|
||||||
|
// ~25% according to benchmarks.
|
||||||
self.sql
|
self.sql
|
||||||
.fetch(
|
.fetch(
|
||||||
sqlx::query(
|
sqlx::query(
|
||||||
@@ -514,7 +519,7 @@ impl Context {
|
|||||||
AND c.blocked=0
|
AND c.blocked=0
|
||||||
AND ct.blocked=0
|
AND ct.blocked=0
|
||||||
AND (m.txt LIKE ? OR ct.name LIKE ?)
|
AND (m.txt LIKE ? OR ct.name LIKE ?)
|
||||||
ORDER BY m.timestamp DESC,m.id DESC;",
|
ORDER BY m.id DESC",
|
||||||
)
|
)
|
||||||
.bind(str_like_in_text)
|
.bind(str_like_in_text)
|
||||||
.bind(str_like_beg),
|
.bind(str_like_beg),
|
||||||
|
|||||||
Reference in New Issue
Block a user