All Products
Search
Document Center

PolarDB:V$SESSION

Last Updated:May 09, 2024

The V$SESSION view presents session information in the current database.

Overview

The V$SESSION view is a dynamic performance view in PolarDB for PostgreSQL (Compatible with Oracle). It presents session information in the current database. A session is the connection between a user and the database. Each time when a user logs on to a database, a new session is created. The V$SESSION view can be used to diagnose session-level problems and query the users connected to the database and their activities.

Each row in the V$SESSION view represents a session that is active or recyclable. The following table describes some of the most commonly used columns in this view:

Column

Type

Description

SID

numeric

Session identifier.

SERIAL#

oid

Serial number of the session. Similar to SID, it uniquely identifies the session.

USERNAME

character varying (128)

Name of the user in the session.

USER#

oid

Internal identifier of the user.

STATUS

character varying (8)

Status of the session, such as ACTIVE, INACTIVE, and KILLED.

SERVER

character varying (9)

Server type, such as DEDICATED (the session is connected through a dedicated server) or SHARED (the session is connected through a shared server).

MACHINE

text

Name of the client machine.

PROGRAM

character varying (30)

Name of the program that started the session.

TYPE

text

Session type, such as USER (which indicates a user session) and BACKGROUND (which indicates a background process session).

SQL_ID

character varying (13)

ID of the SQL statement that is being executed.

LAST_CALL_ET

numeric

The elapsed time (in seconds) since the last calling.

LOGON_TIME

timestamp with time zone

Time of logon.

BLOCKING_SESSION_STATUS

text

Status on whether the session is blocked.

EVENT

text

The event in a wait or most recently waited.

This view is an important tool used by database administrators (DBAs) to monitor, diagnose, and optimize database performance. For example, the DBA can query the V$SESSION view to identify slow sessions, analyze row lock contention, or determine which sessions are consuming the most resources.