1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2002
    Rep Power

    PostgreSQL Books and how to manually close connections to Postgres

    Hi all. I'm wondering how I can go about closing postgresql connections manually via the command line, or if this is something which should generally not be approached, given that I'm using persistent connections.

    Here's the reason for my question:

    I've got four applications which hit different databases on the same server, and last night I wanted to drop one of those databases but I was unable to do so as I kept getting an error message which told me there was still a user connected the database.

    Now, the database I was trying to drop is used by an application which is in the development stage, which means I am the ONLY person using it.

    So when I ran the following command:

    ps auxww | grep ^postgres

    I got a list of all active postgresql connections, and sure enough there was one connection to the database I wanted to drop, and it was over a day old.

    I'm using persistent connections, so I guess I'm looking for two things here:

    1) how long persistent connections are kept in the connection pool after they are idle, and

    2) how I might go about manually terminating said connection so I may drop the database again if need be?

    Also, I've recently been informed that I'm the only person who uses PostgreSQL where I work, and my server administrator is asking that I start to do more of the PostgreSQL administration myself. I have absolutely no problem with this, and am quite excited about the whole process, but I'm going to have to seriously bump up my knowledge of *nix and PostgreSQL.

    Can any of the hardened PostgreSQL gurus on this list recommend some good *nix and PostgreSQL books which I could use as learning tools?

    Thanks very much in advance,
  2. #2
  3. Second highest poster :p
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2001
    Rep Power
    you can stop the PostgreSQL server and it will drop all connections, then you can start it up again and drop the database
    - Andreas Koepke

    Koepke Photography

IMN logo majestic logo threadwatch logo seochat tools logo