Index the file rows with a file on disk (#165)
Counting a person's files through enclosures_entry, once the count was of their own feeds only, read every file row of their 146 feeds to find the few with a file: 58 ms of a feed list, more than the 37-50 ms the count over every row of the table had taken. Production holds 15 files among many thousand rows. A partial index on the rows with a path holds just those, and serves the healthcheck's count and the Downloaded filter too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -65,6 +65,10 @@ async fn create_missing(orm: &sea_orm::DatabaseConnection) -> Result<()> {
|
|||||||
}
|
}
|
||||||
for sql in [
|
for sql in [
|
||||||
"CREATE INDEX IF NOT EXISTS enclosures_entry ON enclosures (feed_id, guid)",
|
"CREATE INDEX IF NOT EXISTS enclosures_entry ON enclosures (feed_id, guid)",
|
||||||
|
// The few rows with a file on disk, 15 of the server's many thousand: counting a person's
|
||||||
|
// files through enclosures_entry read every file row of their feeds, 58 ms a feed list
|
||||||
|
// (#165). Also what the healthcheck's count and the Downloaded filter look for.
|
||||||
|
"CREATE INDEX IF NOT EXISTS enclosures_on_disk ON enclosures (feed_id, guid) WHERE path IS NOT NULL",
|
||||||
"CREATE UNIQUE INDEX IF NOT EXISTS users_name_lower ON users (lower(name))",
|
"CREATE UNIQUE INDEX IF NOT EXISTS users_name_lower ON users (lower(name))",
|
||||||
] {
|
] {
|
||||||
orm.execute_unprepared(sql).await.with_context(|| sql.to_owned())?;
|
orm.execute_unprepared(sql).await.with_context(|| sql.to_owned())?;
|
||||||
|
|||||||
Reference in New Issue
Block a user