diff --git a/session/session.go b/session/session.go index 942ac108a192c..9ec365e7b8a47 100644 --- a/session/session.go +++ b/session/session.go @@ -2256,6 +2256,9 @@ func (s *session) preparedStmtExec(ctx context.Context, execStmt *ast.ExecuteStm is := sessiontxn.GetTxnManager(s).GetTxnInfoSchema() st, tiFlashPushDown, tiFlashExchangePushDown, err := executor.CompileExecutePreparedStmt(ctx, s, execStmt, is) + if err == nil { + err = sessiontxn.OptimizeWithPlanAndThenWarmUp(s, st.Plan) + } if err != nil { return nil, err }