Skip to content
This repository was archived by the owner on Jan 7, 2025. It is now read-only.

Commit 8dcc5a0

Browse files
authored
feat: add cost in RelNodeMeta (#102)
Add the cost in winning `RelNode`s. This potentially enables us to output the cost in `EXPLAIN`, and obtain the estimated cardinality which can be used in q-error computation.
1 parent 86a5888 commit 8dcc5a0

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

optd-core/src/cascades/memo.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ impl<T: RelNodeTyp> Memo<T> {
518518
if let Some(meta) = meta {
519519
meta.insert(
520520
node.as_ref() as *const _ as usize,
521-
RelNodeMeta::new(group_id),
521+
RelNodeMeta::new(group_id, winner.cost),
522522
);
523523
}
524524
return Ok(node);

optd-core/src/rel_node.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::{
1010

1111
use ordered_float::OrderedFloat;
1212

13-
use crate::cascades::GroupId;
13+
use crate::{cascades::GroupId, cost::Cost};
1414

1515
pub type RelNodeRef<T> = Arc<RelNode<T>>;
1616

@@ -208,11 +208,13 @@ impl<T: RelNodeTyp> RelNode<T> {
208208
pub struct RelNodeMeta {
209209
/// The group (id) of the `RelNode`
210210
pub group_id: GroupId,
211+
/// Cost of the `RelNode`
212+
pub cost: Cost,
211213
}
212214

213215
impl RelNodeMeta {
214-
pub fn new(group_id: GroupId) -> Self {
215-
RelNodeMeta { group_id }
216+
pub fn new(group_id: GroupId, cost: Cost) -> Self {
217+
RelNodeMeta { group_id, cost }
216218
}
217219
}
218220

0 commit comments

Comments
 (0)