Skip to content

Commit fd3c93d

Browse files
committed
perf(query-compiler): skip create branch return forwarding
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
1 parent 15b27b8 commit fd3c93d

2 files changed

Lines changed: 6 additions & 24 deletions

File tree

query-compiler/core/src/query_graph_builder/write/nested/connect_or_create_nested.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,6 @@ fn one_to_many_inlined_parent(
414414
let if_node = graph.create_node(Flow::if_non_empty());
415415
let create_node = create::create_record_node(graph, query_schema, child_model.clone(), create_map)?;
416416
let return_existing = graph.create_node(Flow::Return(None));
417-
let return_create = graph.create_node(Flow::Return(None));
418417

419418
graph.create_edge(
420419
&read_node,
@@ -449,12 +448,6 @@ fn one_to_many_inlined_parent(
449448
),
450449
)?;
451450

452-
graph.create_edge(
453-
&create_node,
454-
&return_create,
455-
QueryGraphDependency::ProjectedDataDependency(child_link, RowSink::ProjectedPlaceholder(&ReturnInput), None),
456-
)?;
457-
458451
Ok(())
459452
}
460453

@@ -551,7 +544,6 @@ fn one_to_one_inlined_parent(
551544
let if_node = graph.create_node(Flow::if_non_empty());
552545
let create_node = create::create_record_node(graph, query_schema, child_model.clone(), create_data)?;
553546
let return_existing = graph.create_node(Flow::Return(None));
554-
let return_create = graph.create_node(Flow::Return(None));
555547

556548
graph.create_edge(
557549
&read_node,
@@ -586,16 +578,6 @@ fn one_to_one_inlined_parent(
586578

587579
// Else branch handling
588580
graph.create_edge(&if_node, &create_node, QueryGraphDependency::Else)?;
589-
graph.create_edge(
590-
&create_node,
591-
&return_create,
592-
QueryGraphDependency::ProjectedDataDependency(
593-
child_link.clone(),
594-
RowSink::ProjectedPlaceholder(&ReturnInput),
595-
None,
596-
),
597-
)?;
598-
599581
if utils::node_is_create(graph, &parent_node) {
600582
// No need to perform checks, a child can't exist if the parent is just getting created. Simply inject.
601583
graph.create_edge(

query-compiler/query-compiler/tests/snapshots/queries__queries@create-nested-connectOrCreate-mixed.json.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ transaction
4343
"public"."Post"."id"»
4444
params [const(String("Quantum Topological Embeddings of Mycorrhizal Networks: A Fractal Analysis of Phyllotaxic Algorithms in Non-Euclidean Plant Informatic")),
4545
var(2$id as Int)])
46-
in let 6 = unique (query «SELECT "public"."Category"."id" FROM
46+
in let 5 = unique (query «SELECT "public"."Category"."id" FROM
4747
"public"."Category" WHERE
4848
("public"."Category"."id" = $1 AND 1=1)
4949
LIMIT $2 OFFSET $3»
5050
params [const(BigInt(10)), const(BigInt(1)),
5151
const(BigInt(0))])
52-
in let 8 = if (rowCountNeq 0 (get 6))
53-
then get 6
52+
in let 7 = if (rowCountNeq 0 (get 5))
53+
then get 5
5454
else unique (query «INSERT INTO "public"."Category"
5555
("id","name") VALUES ($1,$2) RETURNING
5656
"public"."Category"."id"»
@@ -60,15 +60,15 @@ transaction
6060
[ rowCountNeq 0
6161
] orRaise "MISSING_RELATED_RECORD");
6262
0$id = mapField id (get 0);
63-
8 = validate (get 8)
63+
7 = validate (get 7)
6464
[ rowCountEq 1
6565
] orRaise "INCOMPLETE_CONNECT_INPUT";
66-
8$id = mapField id (get 8)
66+
7$id = mapField id (get 7)
6767
in execute «INSERT INTO "public"."_CategoryToPost"
6868
("B","A") VALUES [($1),*],* ON CONFLICT DO
6969
NOTHING»
7070
params [product(var(0$id as Int[]),
71-
var(8$id as Int[]))];
71+
var(7$id as Int[]))];
7272
let 0 = unique (validate (get 0)
7373
[ rowCountNeq 0
7474
] orRaise "MISSING_RECORD");

0 commit comments

Comments
 (0)