Skip to content

Commit 77a256b

Browse files
committed
add missing index in repositories table, order updates by oldest first
1 parent 1961aac commit 77a256b

3 files changed

Lines changed: 7 additions & 1 deletion

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DROP INDEX repositories_updated_idx;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CREATE INDEX repositories_updated_idx ON repositories USING btree (updated_at);

crates/lib/docs_rs_repository_stats/src/updater.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,11 @@ impl RepositoryStatsUpdater {
150150
let needs_update: Vec<String> = sqlx::query!(
151151
"SELECT host_id
152152
FROM repositories
153-
WHERE host = $1 AND updated_at < NOW() - INTERVAL '1 day';",
153+
WHERE
154+
host = $1 AND
155+
updated_at < NOW() - INTERVAL '1 day'
156+
ORDER BY updated_at
157+
;",
154158
updater.host()
155159
)
156160
.fetch(&mut *conn)

0 commit comments

Comments
 (0)