Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know the number of database connections

Please note that even though it looks very similar, it's not a duplicate question with this link: How to list active / open connections in Oracle?

I'm not asking about the number of sessions, but connections. I'm aware that I can query the v$session view, but I don't know how many connections are being used there. If there is a way to derive from it, please enlighten me.

EDIT: I'm asking about the physical database connection to the database.

like image 552
Iwan Satria Avatar asked Nov 04 '14 10:11

Iwan Satria


People also ask

How many connections can a database have?

By default, SQL Server allows a maximum of 32767 concurrent connections which is the maximum number of users that can simultaneously log in to the SQL server instance.

How do I see total connections in mysql?

The active or total connection can be known with the help of threads_connected variable. The variable tells about the number of currently open connections. mysql> show status where `variable_name` = 'Threads_connected'; Here is the output.


1 Answers

Bit confused with your statement I'm not asking about the number of sessions, but connections.

Conceptually both are same. Every active session will correspond to a underlying active connection to the database.

Now, if you meant to know the max allowed connection limit then Documentation says

Maximum number of connections (system and application) across all databases in an instance = 2048

To know the allowed session configured to your database, you can query v$parameter view like

SELECT name, value 
  FROM v$parameter
 WHERE name = 'sessions'

If you want to know the Active session at any instance Out of total configured to allow then you can query v$session view using the Status column like

SELECT COUNT(*)
  FROM v$session
WHERE STATUS = 'ACTIVE'

You may want to refer this post How to check the maximum number of allowed connections to an Oracle database?

like image 60
Rahul Avatar answered Oct 22 '22 23:10

Rahul