Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2010
    Posts
    4

    Unanswered: Checking the session status

    Hi all,
    I am using sqlalchemy for the access to a postgresql DB.
    My problem is that I have a loop that creates several processes that in turn create sessions for querying and writing data in the database. It turned out that they are very fast and that more sessions have been created that the DB can handle. Is there any way that I can query the status of DB regarding the number of sessions and their duration and to synchronize the creation of sessions; that is to start new process only after the moment the DB are ready to open new sessions?
    Thankfully

  2. #2
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    Code:
    SELECT *
    FROM pg_stat_activity

  3. #3
    Join Date
    Apr 2010
    Posts
    4
    Hi, thanks for the answer,
    I have got 2 problems:
    !)
    I cannot map this table:
    sqlalchemy.exc.ArgumentError: Mapper Mapper|MyTable|pg_stat_activity could not assemble any primary key columns for mapped table 'pg_stat_activity'
    2) I cannot figure out what is the maximal allowed number of session and which colons are relevant for the session menagement, I see id, port and ip address of the user but how this can be applied for the session management?
    Thanks

  4. #4
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    I cannot map this table:
    I have no idea what "mapping" means, but you might try to prefix it with the correct schema name:
    Code:
    SELECT *
    FROM pg_catalog.pg_stat_activity

    I cannot figure out what is the maximal allowed number of session
    You can find this by using:
    Code:
    SELECT setting
    FROM pg_catalog.pg_settings
    WHERE name = 'max_connections';

    but how this can be applied for the session management?
    Every row in that table is reflects one active session.

    Please read the corresponding chapter about monitoring database activity in the manual:
    http://www.postgresql.org/docs/current/static/monitoring.html

    especially the explanation of the various system tables:
    http://www.postgresql.org/docs/current/static/monitoring-stats.html

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •