Optimize query: Service - Update Workflow Status
File: ee/app/services/ai/duo_workflows/update_workflow_status_service.rb (Line 53)
@workflow.checkpoints.last if @workflow.checkpoints.any?
Generated SQL:
-- First query (exists check):
SELECT 1 AS one
FROM "p_duo_workflows_checkpoints"
WHERE "p_duo_workflows_checkpoints"."workflow_id" = $1
LIMIT 1
-- Second query (if exists):
SELECT "p_duo_workflows_checkpoints".*
FROM "p_duo_workflows_checkpoints"
WHERE "p_duo_workflows_checkpoints"."workflow_id" = $1
ORDER BY "p_duo_workflows_checkpoints"."id" DESC
LIMIT 1
Optimization needed: Ensure queries include created_at filter for partition pruning.