title: Why are there always at least 10 sessions for a postgreSQL database? Why can't they be terminated?
body: <p><strong>Original aim</strong>: rename a database using <code>ALTER DATABASE</code> via psql.<br><br>
  <strong>Problem</strong>: rename fails due to other sessions accessing target database.<br> ・All terminals/applications I am aware of have been closed.
  <br>
  ・querying <code>pg_stat_activity</code> shows that there are 10 processes(=sessions?) accessing the db.<br>・The <code>username</code> for each session is the same user I have been using for psql and for some local phoenix and django apps. The <code>client_addr</code> is also local host for all of them.<br>
  ・When I use <code>pg_terminate_backend</code>, on any of the pids, another process gets immediately spawned.<br>
  ・After restarting my pc, 10 processes are again spawned.</p>
  <p><strong>Concern</strong>: As I can't account for these 10 processes that I can't get rid of, I think I'm misunderstanding how postgres works somewhere.
  <br><br>
  <strong>Question</strong>: Why do 10 session/processes connected to a particular one of my databases, and why can't I terminate them using pg_terminate_backend?
  <br><br>
  Note: In the phoenix project I set up recently, I set the and set the <code>pool_size</code> of the Repo config to 10 - which makes me think it's related...but I'm pretty sure that project isn't running in any way.</p>
  <h1>Update - Solved</h1>
  As a_horse_with_no_name suggested, the by doing the following I was able to put a stop to the 10 mystery sessions.
  <br><br>
    (1) prevent login of user responsible for the sessions (identifiable by querying `pg_stat_activity`), by doing `alter user .... with nologin` <br> <br>
   (2)-running pg_terminate_backend on each of the session's pids.<br><br>
  <p>After those steps I was able to change the table name.
  <br><br>
  The remaining puzzle is, how did those sessions get in that status in the first place... from the contents of pg_stat_activity, the <code>wait_event</code> value for each was <code>clientRead</code>.
  From <a href="https://dba.stackexchange.com/questions/251937/query-hanging-in-clientread-and-blocking-all-others">this post</a>, it seems that the application may have been forcibly stopped halfway through a transaction or something, leaving postgres hanging.</p>