You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select
"platform"."AgentNodeExecution"."id",
"platform"."AgentNodeExecution"."agentGraphExecutionId",
"platform"."AgentNodeExecution"."agentNodeId",
"platform"."AgentNodeExecution"."executionStatus"::text,
"platform"."AgentNodeExecution"."executionData",
"platform"."AgentNodeExecution"."addedTime",
"platform"."AgentNodeExecution"."queuedTime",
"platform"."AgentNodeExecution"."startedTime",
"platform"."AgentNodeExecution"."endedTime",
"platform"."AgentNodeExecution"."stats"
from
"platform"."AgentNodeExecution"
where
(
"platform"."AgentNodeExecution"."agentNodeId" = $1
and "platform"."AgentNodeExecution"."agentGraphExecutionId" = $2
and "platform"."AgentNodeExecution"."executionStatus" = CAST($3::text as "platform"."AgentExecutionStatus")
and ("platform"."AgentNodeExecution"."id") not in (
select
"t1"."referencedByInputExecId"
from
"platform"."AgentNodeExecutionInputOutput" as "t1"
where
(
(not "t1"."name" <> $4)
and "t1"."referencedByInputExecId" is not null
)
)
)
order by
"platform"."AgentNodeExecution"."addedTime" asc
limit
$5
offset
$6 /* traceparent='00-00000000000000000000000000000000-0000000000000000-01' */
which is likely caused by the inner select query that do full table scan most of the time
(
select
"t1"."referencedByInputExecId"
from
"platform"."AgentNodeExecutionInputOutput" as "t1"
where
(
(not "t1"."name" <> $4)
and "t1"."referencedByInputExecId" is not null
)
)
Changes 🏗️
The scope of the change is to avoid the full table call, by trying to load everything without filtering and filters it on the application level.
Checklist 📋
For code changes:
I have clearly listed my changes in the PR description
I have made a test plan
I have tested my changes according to the test plan:
The new implementation loads all executions into memory and filters them in Python code instead of letting the database handle the filtering. This could lead to excessive memory usage if there are many executions.
While this change avoids a full table scan on AgentNodeExecutionInputOutput, it might be less efficient if there are many AgentNodeExecution records but few inputs with the specified name. The database query optimization should be validated with real-world data volumes.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This query is currently the most time consuming
which is likely caused by the inner select query that do full table scan most of the time
Changes 🏗️
The scope of the change is to avoid the full table call, by trying to load everything without filtering and filters it on the application level.
Checklist 📋
For code changes: