Sort and filter by received date on the message cache #172

Merged
jcoffey-dev merged 2 commits from perf/local-received-at into main 2026-10-08 20:02:22 +00:00
2 Commits
Author SHA1 Message Date
jcoffey-dev 68a67be170 Keep the received date whole and answer a mask-only query
ci / fork-checks (pull_request) Skipped
ci / build (pull_request) Skipped
github/ci (branch) GitHub Actions
ci / github (pull_request) Successful in 7m28s
The cache holds the date as u64 and the local sort ranks the messages,
so dates past 2106 no longer tie. A query with no filter beyond the
account used to fall into the local filter, which skips operators and
answered with nothing; it now starts from the mask.
2026-10-08 12:41:40 -07:00
jcoffey-dev 37da91c0a6 Sort and filter by received date on the message cache
The message cache now carries each message's received date. On an SQL
search store a full cache build reads the account's dates from the
search index in one query and the metadata of the messages the index
task has not reached yet; a refresh keeps the dates of the messages it
had and reads the metadata of the new ones, a batch at a time. With any
other search store the dates stay unknown and nothing changes.

With the dates in the cache, JMAP Email/query and IMAP SORT by received
date, Thread/get's ordering, and the before/after/since/on/older/younger
filters run on the cache. Upstream answered each of those with a query
that pulled every message id of the account from the search store in
order, with no limit, on every call.

The PostgreSQL search tables also get an (account, column) index for
each sorted column, so the sorts that still go to the database walk an
ordered index instead of sorting the account's rows.
2026-10-08 12:25:31 -07:00