Skip to content

Sleep and wake

A database nobody is using is put to sleep: its compute, the Postgres process, is removed. Its data stays in the storage. The next connection wakes it.

  • Awake: an ordinary Postgres connection.
  • Asleep: the connection is held at the front door while a compute starts, usually a few seconds (one to six in our tests), and then goes through. Nothing special is needed in the client except patience: allow a connect timeout of a minute.
  • Sessions do not survive a sleep. A database only sleeps when it has no session, so nothing is cut off, but session state and temporary tables from before are gone, as after any reconnect.

For every database, on the Platform (30 minutes by default):

spec:
computes:
idleAfter: 30m

For one database, on the Database, in whole minutes:

spec:
idleAfter: 5m

A change applies to a database that is awake, too.

Terminal window
peat stop orders # asleep now; the next connection wakes it
peat close orders # refuses every connection and stays asleep
peat open orders # takes connections again
peat show orders # says whether it is awake

Use close when a database must not be touched, during an investigation for instance. A closed database does not wake.

There is no “never sleep” switch. A client that holds a session open keeps its database awake; a connection pool with one idle connection is enough. Set a long idleAfter for a database that should ride out quiet periods.