This view records the history of individual database sessions.
Column Name Data Type Description
session_id bigint Unique ID of the session.
application_name varchar(256) Name of the application that is running the session, such as ybsql, ybload, ybunload, or yb-smc. You will also see internal application names such as yb-lime. (Note that an unload session reports ybunload as the application name while it is running. When the unload is complete, the view reports yb-lime as the application name.)
client_hostname varchar(256) Client host name, if available.
client_ip_address varchar(256) Client IP address.
database_id bigint Unique ID for the database.
user_id bigint Unique ID for the database user.
start_time timestamptz Timestamp for when the session started.
end_time timestamptz Timestamp for when the session ended, if it is not still running.
process_id bigint Unique process ID for the session. Used internally for debugging purposes.
secure_connection boolean Whether the database connection is secure (SSL).
last_statement timestamptz When the last SQL statement was started. This column is NULL if the session did not execute any statements.
state varchar(256) If the session was shut down because of idle_in_transaction_timeout, the state is 25P03. If the session was shut down because of idle_session_timeout, the state is 25P04. Other states are idle and active. See also Managing Idle Sessions.
secure_details varchar(256) For secure connections, the SSL version, cipher, and key size.


Join sys.log_session to sys.database to return information about ybsql sessions that lasted longer than 1 second:
premdb=# select dbname, sd.database_id, user_id, session_id, application_name, end_time-start_time duration 
from sys.database sd, sys.log_session sls where sd.database_id=sls.database_id 
and application_name ='ybsql' and duration>'1 sec' 
order by sd.database_id, session_id;
      dbname      | database_id | user_id | session_id | application_name |    duration     
 yellowbrick_test |       16588 |   16590 |      17232 | ybsql            | 00:00:11.774066
 yellowbrick_test |       16588 |   16590 |      18279 | ybsql            | 00:00:19.486412
 yellowbrick_test |       16588 |   16590 |      19941 | ybsql            | 00:00:30.966864
 yellowbrick_test |       16588 |   16590 |      23253 | ybsql            | 00:18:08.167864
 premdb           |       26259 |   26261 |      23285 | ybsql            | 00:00:35.007097
 premdb           |       26259 |   26261 |      23445 | ybsql            | 00:00:54.950788
(6 rows)