@@ -136,18 +136,26 @@ private void handleExecute(PrepareStmt prepareStmt, long stmtId) {
136
136
executor = new StmtExecutor (ctx , executeStmt );
137
137
ctx .setExecutor (executor );
138
138
executor .execute ();
139
- PrepareStmtContext preparedStmtContext = ConnectContext .get ().getPreparedStmt (String .valueOf (stmtId ));
140
- if (preparedStmtContext != null ) {
141
- stmtStr = executeStmt .toSql ();
139
+ //For the `insert into` statements during group commit load via JDBC.
140
+ //Printing audit logs can severely impact performance.
141
+ //Therefore, we have introduced a session variable to control whether to print audit logs.
142
+ //It is recommended to turn off audit logs only during group commit load via JDBC.
143
+ if (ctx .getSessionVariable ().isEnablePreparedStmtAuditLog ()) {
144
+ PrepareStmtContext preparedStmtContext = ConnectContext .get ().getPreparedStmt (String .valueOf (stmtId ));
145
+ if (preparedStmtContext != null ) {
146
+ stmtStr = executeStmt .toSql ();
147
+ }
142
148
}
143
- } catch (Throwable e ) {
149
+ } catch (Throwable e ) {
144
150
// Catch all throwable.
145
151
// If reach here, maybe doris bug.
146
152
LOG .warn ("Process one query failed because unknown reason: " , e );
147
153
ctx .getState ().setError (ErrorCode .ERR_UNKNOWN_ERROR ,
148
154
e .getClass ().getSimpleName () + ", msg: " + e .getMessage ());
149
155
}
150
- auditAfterExec (stmtStr , executor .getParsedStmt (), executor .getQueryStatisticsForAuditLog (), true );
156
+ if (ctx .getSessionVariable ().isEnablePreparedStmtAuditLog ()) {
157
+ auditAfterExec (stmtStr , executor .getParsedStmt (), executor .getQueryStatisticsForAuditLog (), true );
158
+ }
151
159
}
152
160
153
161
private void handleExecute (PrepareCommand prepareCommand , long stmtId , PreparedStatementContext prepCtx ) {
@@ -199,15 +207,19 @@ private void handleExecute(PrepareCommand prepareCommand, long stmtId, PreparedS
199
207
executor = new StmtExecutor (ctx , stmt );
200
208
ctx .setExecutor (executor );
201
209
executor .execute ();
202
- stmtStr = executeStmt .toSql ();
203
- } catch (Throwable e ) {
210
+ if (ctx .getSessionVariable ().isEnablePreparedStmtAuditLog ()) {
211
+ stmtStr = executeStmt .toSql ();
212
+ }
213
+ } catch (Throwable e ) {
204
214
// Catch all throwable.
205
215
// If reach here, maybe doris bug.
206
216
LOG .warn ("Process one query failed because unknown reason: " , e );
207
217
ctx .getState ().setError (ErrorCode .ERR_UNKNOWN_ERROR ,
208
218
e .getClass ().getSimpleName () + ", msg: " + e .getMessage ());
209
219
}
210
- auditAfterExec (stmtStr , executor .getParsedStmt (), executor .getQueryStatisticsForAuditLog (), true );
220
+ if (ctx .getSessionVariable ().isEnablePreparedStmtAuditLog ()) {
221
+ auditAfterExec (stmtStr , executor .getParsedStmt (), executor .getQueryStatisticsForAuditLog (), true );
222
+ }
211
223
}
212
224
213
225
// process COM_EXECUTE, parse binary row data
0 commit comments