lemmy
lemmy copied to clipboard
Using prepared queries for scheduled tasks
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.
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