dataiotech Labs
dbaguidedbaguideDBAdataxtoolsdataopsphere
Home/Glossary/Session
SessionArchitecture & Connectivity

Database Session (Veritabanı Oturumu & Durum Kapsamı)

The logical stateful context instantiated upon successful client authentication that holds GUC parameters, prepared statements, session-scoped locks, and temporary tables until disconnect or DISCARD ALL.

Internal Architecture Breakdown

A session is the stateful bridge between a physical transport connection and individual transactions. When a transaction ends (COMMIT / ROLLBACK), session-level states such as SET timezone, session-scoped advisory locks, and temporary tables persist until explicitly cleared.

Under transaction pooling (e.g. PgBouncer transaction mode), server connections are released at transaction boundaries, creating state leakage risks if session-level variables are modified. Stateless applications should prefer transaction-scoped settings like SET LOCAL or SET ... FOR TRANSACTION, which automatically revert upon commit or rollback.

TIP
Architectural Deep Dive: For session state boundaries and pooling implications, see: PostgreSQL Connection Management: Lifecycle, Capacity, and Pooling.

Production Inspection Queries

PostgreSQL
SELECT pid, usename, client_addr, state, backend_start, state_change FROM pg_stat_activity WHERE backend_type = 'client backend';
MySQL
SELECT id, user, host, db, command, time, state FROM information_schema.processlist;