sys.execution_id()

Return the execution ID of the running query.
sys.execution_id()

To return a meaningful result, always use this function in a query with a table reference, such as a reference to sys.const.

For example:
premdb=# select sys.execution_id() from sys.const;
 execution_id 
--------------
      6051039
(1 row)