LOCALSTATEMENTSLASTEXECUTION System Table Description
Description
The LOCALSTATEMENTSLASTEXECUTION
pseudo table provides information about the last executed SQL statement by a user.
Specifically, the table provides details about the last finished execution, current memory usage, and the last applied garbage collection.
Client applications should never contain code that accesses SYSTEM pseudo tables as they are subject to, and furthermore likely to, change from release to release. |
Fields
Field | Type | Description |
---|---|---|
COMPILATION_DURATION |
BigInt |
Duration of the last compilation, in microseconds. |
COMPILATION_TIMESTAMP |
Timestamp |
The start time of the last compilation, in |
CONNECTION_ID |
BigInt |
ID of the owning connection. |
EXECUTION_COUNT |
Integer |
Number of (non-distinct) SQL statements executed by the statement. |
EXECUTION_DURATION |
BigInt |
Duration of the last execution, in microseconds. |
EXECUTION_TIMESTAMP |
Timestamp |
Start time of the last execution, in |
GARBAGE_COLLECTION_TIMESTAMP |
Timestamp |
Start time of the last garbage collection, in |
GENERATED_KEYS |
Integer |
Number of keys generated by the last execution. |
GENERATED_RESULTS |
Integer |
Number of rows contained in the result of the last execution. |
MEM_USAGE_CURRENT |
BigInt |
Current memory usage. |
MEM_USAGE_PEAK |
BigInt |
Maximum memory used by the last execution. |
MEM_USAGE_PREPARED |
BigInt |
Memory required after the compilation. |
STATEMENT |
String |
Last executed SQL statement. |
STATEMENT_HANDLE |
Integer |
Handle ID of the SQL statement. |
TRANSACTION_ID |
Integer |
ID of the transaction used for the last execution. |
Example
In this example, queries were executed on two different connections using the same user.
SELECT 1 FROM dual;
[1]
----
1
(1 row returned in 1.59ms)
SELECT * FROM system.localstatementslastexecution;
COMPILATION_DURATION COMPILATION_TIMESTAMP CONNECTION_ID EXECUTION_COUNT EXECUTION_DURATION EXECUTION_TIMESTAMP GARBAGE_COLLECTION_TIMESTAMP GENERATED_KEYS GENERATED_RESULTS MEM_USAGE_CURRENT MEM_USAGE_PEAK MEM_USAGE_PREPARED STATEMENT STATEMENT_HANDLE TRANSACTION_ID
--------------------- -------------------------- -------------- ---------------- ------------------- -------------------------- ----------------------------- --------------- ------------------ ------------------ --------------- ------------------- ------------------- ----------------- ---------------
<null> <null> 4294967299 <null> <null> <null> <null> <null> <null> 10360 <null> <null> <null> 1 <null>
948 2025-10-07 15:10:07.546764 4294967300 2 172 2025-10-07 15:10:07.547715 <null> 0 1 4992 5024 4992 select 1 from dual; 1 1921
»
(2 rows returned in 3.39ms)
Null values in the field indicate that the corresponding information is not available. For example, if no statement has been finished or compiled yet, or if the statement has not yet been affected by the garbage collection.
Execute the same statement on connection 2:
SELECT * FROM system.localstatementslastexecution;
COMPILATION_DURATION COMPILATION_TIMESTAMP CONNECTION_ID EXECUTION_COUNT EXECUTION_DURATION EXECUTION_TIMESTAMP GARBAGE_COLLECTION_TIMESTAMP GENERATED_KEYS GENERATED_RESULTS MEM_USAGE_CURRENT MEM_USAGE_PEAK MEM_USAGE_PREPARED STATEMENT STATEMENT_HANDLE TRANSACTION_ID
--------------------- -------------------------- -------------- ---------------- ------------------- -------------------------- ----------------------------- --------------- ------------------ ------------------ --------------- ------------------- -------------------------------------------------- ----------------- ---------------
1081 2025-10-07 15:10:28.337105 4294967299 1 1528 2025-10-07 15:10:28.33819 <null> 0 1 10360 10520 10488 select * from system.localstatementslastexecution; 1 2305
»
948 2025-10-07 15:10:07.546764 4294967300 2 172 2025-10-07 15:10:07.547715 <null> 0 1 4992 5024 4992 select 1 from dual; 1 1921
»
(2 rows returned in 1.07ms)