is max connections in a database table somewhere

Started by Geoffrey Myersover 14 years ago4 messagesgeneral
Jump to latest
#1Geoffrey Myers
geof@serioustechnology.com

Is the max connections value in a system table somewhere?

Thanks.

--
Geoffrey Myers
Myers Consulting Inc.
770.592.1651

#2Greg Smith
gsmith@gregsmith.com
In reply to: Geoffrey Myers (#1)
Re: is max connections in a database table somewhere

On 08/10/2011 02:46 PM, Geoffrey Myers wrote:

Is the max connections value in a system table somewhere?

If you intend to do anything with the value you probably want one of
these forms:

SELECT CAST(current_setting('max_connections') AS integer);
SELECT CAST(setting AS integer) FROM pg_settings WHERE
name='max_connections';

The setting comes back as a text field when using current_setting on the
pg_settings view (which isn't a real table, under the hood it's calling
a system function)

--
Greg Smith 2ndQuadrant US greg@2ndQuadrant.com Baltimore, MD
PostgreSQL Training, Services, and 24x7 Support www.2ndQuadrant.us

#3Diego Augusto Molina
diegoaugustomolina@gmail.com
In reply to: Greg Smith (#2)
Re: is max connections in a database table somewhere

2011/8/10, Greg Smith <greg@2ndquadrant.com>:

On 08/10/2011 02:46 PM, Geoffrey Myers wrote:

Is the max connections value in a system table somewhere?

Yes, it is in the table "pg_catalog.pg_database". The column is named
"datconnlimit" and is of type "int4". See this:
http://www.postgresql.org/docs/9.0/interactive/catalog-pg-database.html.

But this would be the appropiate way of getting the value:

SELECT CAST(current_setting('max_connections') AS integer);

You would rather use that form instead of messing up with the catalogs.
--
Diego Augusto Molina
diegoaugustomolina@gmail.com

ES: Por favor, evite adjuntar documentos de Microsoft Office. Serán
desestimados.
EN: Please, avoid attaching Microsoft Office documents. They shall be discarded.
LINK: http://www.gnu.org/philosophy/no-word-attachments.html

#4Geoffrey
lists@serioustechnology.com
In reply to: Greg Smith (#2)
Re: is max connections in a database table somewhere

Greg Smith wrote:

On 08/10/2011 02:46 PM, Geoffrey Myers wrote:

Is the max connections value in a system table somewhere?

If you intend to do anything with the value you probably want one of
these forms:

SELECT CAST(current_setting('max_connections') AS integer);
SELECT CAST(setting AS integer) FROM pg_settings WHERE
name='max_connections';

The setting comes back as a text field when using current_setting on the
pg_settings view (which isn't a real table, under the hood it's calling
a system function)

Actually, just pulling it out of the database to display it in a report.

--
Until later, Geoffrey

"I predict future happiness for America if they can prevent
the government from wasting the labors of the people under
the pretense of taking care of them."
- Thomas Jefferson