lemmy icon indicating copy to clipboard operation
lemmy copied to clipboard

Using prepared queries for scheduled tasks

Open Nutomic opened this issue 11 months ago • 1 comments

Based on this discussion, diesel doesnt use prepared query cache for raw sql queries which we use for some of the scheduled tasks. This can result in much slower queries. So it may be worth manually implementign QueryFragment for those, or better yet getting a function prepared_sql() merged upstream. Or maybe the queries can be rewritten without raw sql.

Nutomic avatar Jan 31 '25 21:01 Nutomic

For reference, here's the WITH query we should try to convert to pure diesel: https://github.com/LemmyNet/lemmy/blob/main/crates/routes/src/utils/scheduled_tasks.rs#L217

dessalines avatar Feb 01 '25 18:02 dessalines