With PostgreSQL, what is the difference between a session and a connection

PostgreSQL world :

With pgbadger (postgres tool), some results speak about SESSIONS, others about CONNECTIONS.

With PostgreSQL, what is the difference between a session and a connection ?

Your site contains the answer for Oracle but not for Postgres...

Thanks a lot.

Gery
Géry PANNEQUINConsultantAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lcohanDatabase AnalystCommented:
That is actually defined here: https://severalnines.com/blog/postgresql-log-analysis-pgbadger

Session: Total number of sessions, peak sessions time, total duration of sessions, average duration of sessions, average queries found per session, average queries duration per session.
Connections: Total number of connections, peak connections, and total number of databases connected to.

Normally there is one session on each connection, but there could be multiple session on a single connection and there are also sessions that have no connection.

The link below is an example of multiple sessions per connection provided by pgbadger:
https://www.postgresql.org/message-id/53BC1C3F.1000407@pinpointresearch.com
Géry PANNEQUINConsultantAuthor Commented:
Thanks Icohan for the text and the links.
I should be happy to have more details about :
Normally there is one session on each connection, but there could be multiple session on a single connection and there are also sessions that have no connection.
Best regards,
Gery
lcohanDatabase AnalystCommented:
One fast example that comes to my mind is "MARS - Multiple Active Result Sets" and explanation about what they are and how they are implemented can be found here: https://github.com/npgsql/npgsql/issues/462
One reason to not do what someone suggested at above link "Why don't EF simply open another connection?" is that Postgres has usually a limited number of connections set in its config files as they tie directly to hardware resources so is not like other DB engines where new connection may not matter too much so you just through another connection at DB to do whatever work that could have been done on another connection.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PostgreSQL

From novice to tech pro — start learning today.