Skip to main content

fuse_create_set

Function fuse_create_set 

Source
pub fn fuse_create_set(plan: LogicalPlan) -> LogicalPlan
Expand description

Fold a trailing SET var.prop = value into the freshly-created entity’s inline property map, eliminating the separate Set write pass.

Rewrites CREATE (a)-[r:T]->(b) SET r.x = e.v into the equivalent of CREATE (a)-[r:T {x: e.v}]->(b), so the plan collapses from Set → Create to a single Create. This removes an entire read-modify-write operator (MutationSetExec) — measured at ~38% of per-edge UNWIND … CREATE … SET execution — that the bulk write path never pays.

§Examples

// CREATE (a)-[r:LINK]->(b) SET r.role = e.role   ==>
// CREATE (a)-[r:LINK {role: e.role}]->(b)
let fused = fuse_create_set(plan);

The fold is all-or-nothing per SET clause and only fires when every item is safe:

  • the item is the simple Variable.property = value form (not +=, label set SET n:L, or whole-entity map assignment SET n = {...}),
  • the target variable is introduced by the immediately-preceding Create/CreateBatch (a MATCHed variable is left untouched),
  • the target element’s inline properties are absent or a map literal (a parameter-map form such as CREATE (n $props) cannot be merged),
  • the value references no variable created in the same statement, so evaluating it at create time is observably identical to SET time.

When any item fails these checks the whole Set node is preserved, keeping semantics unchanged. The pass is idempotent: a plan with no fusable Set/Create adjacency passes through untouched.