Skip to content

Commit

Permalink
perf: remove redundant read on upsert (#4248)
Browse files Browse the repository at this point in the history
  • Loading branch information
Weakky committed Sep 18, 2023
1 parent 79f2257 commit 237634d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions query-engine/core/src/query_graph_builder/write/upsert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,23 @@ pub(crate) fn upsert_record(
}

graph.create_edge(&if_node, &create_node, QueryGraphDependency::Else)?;

// Pass-in the read parent record result to the update node RecordFilter to avoid a redundant read.
graph.create_edge(
&read_parent_records_node,
&update_node,
QueryGraphDependency::ProjectedDataDependency(
model_id.clone(),
Box::new(move |mut update_node, parent_ids| {
if let Node::Query(Query::Write(WriteQuery::UpdateRecord(ref mut ur))) = update_node {
ur.set_selectors(parent_ids);
}

Ok(update_node)
}),
),
)?;

graph.create_edge(
&update_node,
&read_node_update,
Expand Down

0 comments on commit 237634d

Please sign in to comment.