#[derive(Debug, Clone)]
pub struct CostEstimator {
pub seq_page_cost: f64,
pub random_page_cost: f64,
pub cpu_tuple_cost: f64,
pub cpu_index_tuple_cost: f64,
pub rows_per_page: f64,
pub insert_tuple_cost: f64,
pub hash_index_update_cost: f64,
pub btree_index_update_cost: f64,
pub update_tuple_cost: f64,
pub delete_tuple_cost: f64,
pub compaction_cost_multiplier: f64,
pub columnar_rebuild_cost: f64,
pub columnar_cache_invalidation_cost: f64,
pub wal_write_cost: f64,
pub wal_sync_cost: f64,
}
impl Default for CostEstimator {
fn default() -> Self {
Self {
seq_page_cost: 1.0,
random_page_cost: 1.5,
cpu_tuple_cost: 0.01,
cpu_index_tuple_cost: 0.005,
rows_per_page: 100.0,
insert_tuple_cost: 0.1,
hash_index_update_cost: 0.05,
btree_index_update_cost: 0.15,
update_tuple_cost: 0.08,
delete_tuple_cost: 0.05,
compaction_cost_multiplier: 2.0,
columnar_rebuild_cost: 0.02,
columnar_cache_invalidation_cost: 0.1,
wal_write_cost: 0.12,
wal_sync_cost: 0.5,
}
}
}
impl CostEstimator {
pub fn new(
seq_page_cost: f64,
random_page_cost: f64,
cpu_tuple_cost: f64,
cpu_index_tuple_cost: f64,
) -> Self {
let default = Self::default();
Self {
seq_page_cost,
random_page_cost,
cpu_tuple_cost,
cpu_index_tuple_cost,
rows_per_page: 100.0,
insert_tuple_cost: default.insert_tuple_cost,
hash_index_update_cost: default.hash_index_update_cost,
btree_index_update_cost: default.btree_index_update_cost,
update_tuple_cost: default.update_tuple_cost,
delete_tuple_cost: default.delete_tuple_cost,
compaction_cost_multiplier: default.compaction_cost_multiplier,
columnar_rebuild_cost: default.columnar_rebuild_cost,
columnar_cache_invalidation_cost: default.columnar_cache_invalidation_cost,
wal_write_cost: default.wal_write_cost,
wal_sync_cost: default.wal_sync_cost,
}
}
}