473,378 Members | 1,422 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

How to know the Number of Connection made with the database

18
hi friends,

I would like to know the number of connections made with a particular database and at the same time i like to restrict the number of connections from my VC++ Application. I am Using yhe 'libpq' interface. Is it there any way to do this.

ThanQ
Mar 14 '07 #1
1 16335
michaelb
534 Expert 512MB
There is a number of ways to get the connection count, including these:

Expand|Select|Wrap|Line Numbers
  1. template1=# select datname, count(*) from pg_stat_activity group by datname;
  2.   datname  | count 
  3. -----------+-------
  4.  testdb    |     5
  5.  template1 |     1
  6. (2 rows)
  7.  
  8. template1=# select datname, numbackends from pg_stat_database;
  9.   datname  | numbackends 
  10. -----------+-------------
  11.  testdb    |           5
  12.  template1 |           1
  13.  template0 |           0
  14. (3 rows)
  15.  
Obviously you can use the WHERE clause in your query to get just the number of connections for particular database.

You can limit the number of connections using the run-time parameter max_connections
This setting controls the overall connection limit for the server, so if you have more than one
database there this option may not be very helpful.

Starting with version 8.1 you can control connection limit per user and per database, using
ALTER USER and ALTER DATABASE respectively.
Mar 14 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Wojciech Halicki-Piszko | last post by:
How to know if connection is active after telnetlib.Telnet.open(host,port)?
4
by: Digital Fart | last post by:
howto make a connection to database available in my classes. What is the best practice when i want to write classes that need a connection to the database? Do i make a conn variable in my...
3
by: Maellic | last post by:
Hi, The website I am working on is built with ASP.NET and connects to a SQL Server 2000 database. The web server and database are on the same machine. I have recently tried to modify the timeout...
6
by: Mikeland | last post by:
Please, can you help me about this error: SQL1091C The release number of the database is not valid. SQLSTATE=08004 I connect to a db Version: 7, Release: 1 whit a database manager Version:...
1
by: sharadadutt1981 | last post by:
hi all, I was trying to fetch even or odd number rows from database. currently i am usying DB2 ver 8.0. any one can help me out.
2
by: Nitu Thakkar | last post by:
Hello There My question is that how can i Provide the dynemic connection in database in asp.net please provide the code for that & how...
6
by: chazzy69 | last post by:
Not sure if this is where i should be posting this question but here goes anyways; As the title indicates im trying to setup a remote connection to a database, i have added access for the remote...
1
by: =?Utf-8?B?c25henp5?= | last post by:
Connection to ODBC Database works OK while in the Visual Studio 2008 Debug mode. However after building the Web Application and publishing the files for project, an error occurs; Server Error in...
0
by: Peter910 | last post by:
Dear Members of the house, Is there any version of the Dreamweaver, alongside with PHP, that uses ODBC connection to database? If there is, or any other GUI software of connecting to database...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.