mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-11-29 14:00:31 +08:00
node/db: Index routing by node
`sync_routing` calls `get_inventory(&from)` once per inbound inventory
announcement, to work out which of a peer's previously-announced repos are
no longer in its inventory:
// crates/radicle-protocol/src/service.rs
synced.removed.extend(
self.db.routing().get_inventory(&from)?
.into_iter()
.filter(|rid| !included.contains(rid)),
);
That is `SELECT repo FROM routing WHERE node = ?`. The table's only index is
the implicit one for the primary key `(repo, node)`, whose leading column is
`repo`, so the lookup cannot use it and scans instead. The index fixes that.
This commit is contained in:
committed by
Lorenz Leutgeb
parent
2f930e3561
commit
736d21f606
@@ -40,6 +40,7 @@ const MIGRATIONS: &[&str] = &[
|
||||
include_str!("db/migrations/7.sql"),
|
||||
include_str!("db/migrations/8.sql"),
|
||||
include_str!("db/migrations/9.sql"),
|
||||
include_str!("db/migrations/10.sql"),
|
||||
];
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
-- `get_inventory` looks routing entries up by node alone, once per inbound
|
||||
-- inventory announcement. The table's only index is the implicit one for the
|
||||
-- primary key `(repo, node)`, whose leading column is `repo`, so that lookup
|
||||
-- scans -- tens of thousands of rows on a seed following a busy network.
|
||||
create index if not exists "routing_node" on "routing" ("node");
|
||||
Reference in New Issue
Block a user