Skip to content

Commit 3cec08f

Browse files
Remove redundant indexes
1 parent 1c3572e commit 3cec08f

3 files changed

Lines changed: 15 additions & 24 deletions

File tree

crates/client-api/src/routes/database.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,12 +289,10 @@ fn reducer_outcome_response(
289289
axum::Json(sats::serde::SerdeWrapper(value)).into_response(),
290290
))
291291
}
292+
} else if want_bsatn {
293+
Ok((StatusCode::OK, Vec::<u8>::new().into_response()))
292294
} else {
293-
if want_bsatn {
294-
Ok((StatusCode::OK, Vec::<u8>::new().into_response()))
295-
} else {
296-
Ok((StatusCode::OK, "".into_response()))
297-
}
295+
Ok((StatusCode::OK, "".into_response()))
298296
}
299297
}
300298
ReducerOutcome::Failed(errmsg) => {

modules/tpcc/src/lib.rs

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,7 @@ pub struct Warehouse {
105105
pub w_ytd_cents: i64,
106106
}
107107

108-
#[table(
109-
accessor = district,
110-
index(accessor = by_w_d, btree(columns = [d_w_id, d_id]))
111-
)]
108+
#[table(accessor = district)]
112109
#[derive(Clone, Debug)]
113110
pub struct District {
114111
#[primary_key]
@@ -128,7 +125,6 @@ pub struct District {
128125

129126
#[table(
130127
accessor = customer,
131-
index(accessor = by_w_d_c_id, btree(columns = [c_w_id, c_d_id, c_id])),
132128
index(accessor = by_w_d_last_first_id, btree(columns = [c_w_id, c_d_id, c_last, c_first, c_id]))
133129
)]
134130
#[derive(Clone, Debug)]
@@ -185,10 +181,7 @@ pub struct Item {
185181
pub i_data: String,
186182
}
187183

188-
#[table(
189-
accessor = stock,
190-
index(accessor = by_w_i, btree(columns = [s_w_id, s_i_id]))
191-
)]
184+
#[table(accessor = stock)]
192185
#[derive(Clone, Debug)]
193186
pub struct Stock {
194187
#[primary_key]
@@ -776,29 +769,29 @@ fn ensure_warehouse_exists(tx: &ReducerContext, w_id: WarehouseId) -> Result<(),
776769
}
777770

778771
fn find_district(tx: &ReducerContext, w_id: WarehouseId, d_id: u8) -> Result<District, String> {
772+
let district_key = pack_district_key(w_id, d_id);
779773
tx.db
780774
.district()
781-
.by_w_d()
782-
.filter((w_id, d_id))
783-
.next()
775+
.district_key()
776+
.find(district_key)
784777
.ok_or_else(|| format!("district ({w_id}, {d_id}) not found"))
785778
}
786779

787780
fn find_customer_by_id(tx: &ReducerContext, w_id: WarehouseId, d_id: u8, c_id: u32) -> Result<Customer, String> {
781+
let customer_key = pack_customer_key(w_id, d_id, c_id);
788782
tx.db
789783
.customer()
790-
.by_w_d_c_id()
791-
.filter((w_id, d_id, c_id))
792-
.next()
784+
.customer_key()
785+
.find(customer_key)
793786
.ok_or_else(|| format!("customer ({w_id}, {d_id}, {c_id}) not found"))
794787
}
795788

796789
fn find_stock(tx: &ReducerContext, w_id: WarehouseId, item_id: u32) -> Result<Stock, String> {
790+
let stock_key = pack_stock_key(w_id, item_id);
797791
tx.db
798792
.stock()
799-
.by_w_i()
800-
.filter((w_id, item_id))
801-
.next()
793+
.stock_key()
794+
.find(stock_key)
802795
.ok_or_else(|| format!("stock ({w_id}, {item_id}) not found"))
803796
}
804797

tools/tpcc-runner/src/module_bindings/mod.rs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)