How can I view the execution time of a SQL statement in DB2?

In DB2, you can use the following command to view the execution time of a SQL statement:

SET QUERY ACCELERATION OFF;
SET CURRENT EXPLAIN MODE EXPLAIN;
EXPLAIN PLAN FOR [your_sql_statement_here];
SELECT ELAPSED_TIME, TOTAL_COST, CARDINALITY FROM SYSIBM.SYSHEXPLAINS;

Before executing the SQL, make sure to set some parameters to ensure accurate information on the actual execution time (ELAPSED_TIME), total cost (TOTAL_COST), and other details such as the number of rows based on statistical information and optimizer predictions (CARDINALITY).

bannerAds