Managing Client Connections

This section explains how you can control the way clients connect to your database. Vertica gives you several settings to control client connections:

  • Limit the number of client connections a user can have open at the same time.
  • Limit the time a client connection can be idle before being automatically disconnected.
  • Use connection load balancing to spread the overhead of servicing client connections among nodes.

Total client connections to a given node cannot exceed the limits set in MaxClientSessions.

Changes to a client's MAXCONNECTIONS property have no effect on current sessions; these changes apply only to new sessions. For example, if you change user's connection mode from DATABASE to NODE, current node connections are unaffected. This change applies only to new sessions, which are reserved on the invoking node.

Limiting Idle Session Length

Idle sessions eventually time out. The maximum time that sessions are allowed to idle can set at three levels, in descending order of precedence:

  • As dbadmin, set the IDLESESSIONTIMEOUT property for individual users. This property overrides all other session timeout settings.
  • Users can limit the idle time of the current session with SET SESSION IDLESESSIONTIMEOUT. Non-superusers can only set their session idle time to a value equal to or lower than their own IDLESESSIONTIMEOUT setting. If no session idle time is explicitly set for a user, the session idle time for that user is inherited from the node or database settings.
  • As dbadmin, set configuration parameter DEFAULTIDLESESSIONTIMEOUT. on the database or on individual nodes. This You can limit the default database cluster or individual nodes, with configuration parameter DEFAULTIDLESESSIONTIMEOUT. This parameter sets the default timeout value for all non-superusers.

All settings apply to sessions that are continuously idle—that is, sessions where no queries are running. If a client is slow or unresponsive during query execution, that time does not apply to timeouts. For example, the time that is required for a streaming batch insert is not counted towards timeout. The server identifies a session as idle starting from the moment it starts to wait for any type of message from that session.

Viewing Session Settings

Session length limits


           name            | setting
 DefaultIdleSessionTimeout | 2 day
(1 row)

Current session

        name        | setting
 idlesessiontimeout | 1
(1 row)
Connection limits


       name        | setting
 MaxClientSessions | 50
(1 row)


=> SELECT user_name, max_connections, connection_limit_mode FROM users 
     WHERE user_name != 'dbadmin';
 user_name | max_connections | connection_limit_mode
 SuzyX     | 3               | database
 Joe       | 10              | database
(2 rows)

Closing User Sessions

If necessary, you can manually close a user session with CLOSE_USER_SESSIONS:

 Close all sessions for user Joe sent. Check v_monitor.sessions for progress.
(1 row)

Use Case Example

A user executes a query, and for some reason the query takes an unusually long time to finish (for example, because of server traffic or query complexity). In this case, the user might think the query failed, and opens another session to run the same query. Now, two sessions run the same query, using an extra connection.

To prevent this situation, you can limit how many sessions individual users can run, by modifying their MAXCONNECTIONS user property. This can help minimize the chances of running redundant queries. It also helps prevent users from consuming all available connections, as set by the database For example, the following setting on user SuzyQ limits her to two database sessions at any time:


Limiting Another issue setting client connections prevents is when a user connects to the server many times. Too many user connections exhausts the number of allowable connections set by database configuration parameter MaxClientSessions.

No user can have a MAXCONNECTIONS limit greater than the MaxClientSessions setting.

Cluster Changes and Connections

Behavior changes can occur with client connection limits when the following changes occur to a cluster:

  • You add or remove a node.
  • A node goes down or comes back up.

Changes in node availability between connection requests have little impact on connection limits.

In terms of honoring connection limits, no significant impact exists when nodes go down or come up in between connection requests. No special actions are needed to handle this. However, if a node goes down, its active session exits and other nodes in the cluster also drop their sessions. This frees up connections. The query may hang in which case the blocked sessions are reasonable and as expected.

In This Section