Database instance

On this page 7

A database instance is the running copy of database management software, meaning the set of operating system processes, threads and shared memory structures that a DBMS starts in order to serve queries against stored data. Database fundamentals draw a sharp line between the instance, which is volatile and lives in memory, and the database itself, which is the persistent collection of data files on disk.

The distinction matters in daily operations. An instance can be started, stopped, restarted or failed over without the data being lost, and in some architectures several instances serve the same database files at once, while in others one instance hosts many databases. Knowing which model a given system uses is essential for capacity planning, security and recovery.

What a database instance consists of

Every database instance combines memory areas, background workers and network listeners, even though vendors name them differently. When the instance starts, it allocates memory, launches its workers, opens or mounts the data files and begins accepting client sessions.

ComponentFunctionExamples
Buffer cacheHolds recently used data pages in memoryOracle buffer cache, PostgreSQL shared buffers
Log buffer and writerRecords changes for durability and recoveryRedo log writer, WAL writer
Background processesCheckpoints, cleanup, statistics, replicationCheckpointer, autovacuum, lazy writer
Session processesExecute SQL on behalf of each clientServer process per connection, worker threads
Listener or portAccepts incoming client connectionsTCP port 5432, 1521, 1433 or 3306
ConfigurationDefines memory sizes and limitsParameter file, postgresql.conf, my.cnf
Main components of a database instance

The buffer cache is usually the largest consumer of memory, often sized between 25 and 75 percent of server RAM depending on the engine and on whether the operating system cache is also relied upon. Because these structures exist only while the instance runs, a crash empties them, and the engine must replay the transaction log at the next startup to bring the data files to a consistent state.

Instance versus database across major DBMS products

The relationship between an instance and the databases it serves differs significantly between products, and terminology confusion is a frequent source of operational mistakes. In Oracle Database the classic model is one instance per database, whereas PostgreSQL, SQL Server and MySQL let one instance serve many databases.

DBMSName for the instanceDatabases per instance
Oracle DatabaseInstance (SGA plus background processes)One database, or many pluggable databases in a container
Oracle RACMultiple instances on separate nodesMany instances share one database
PostgreSQLCluster served by one postmasterMany databases in one data directory
SQL ServerNamed or default instanceMany databases, including system databases
MySQLServer process mysqldMany schemas, which MySQL calls databases
How major products map instances to databases

In cloud services the word acquires a further meaning: a managed service such as Amazon RDS uses DB instance for the provisioned virtual server, including its compute class, storage and network endpoint. In that context an instance is also a billing and scaling unit, so resizing it changes cost and capacity rather than only memory settings.

Instance lifecycle and startup states

An instance moves through distinct states between shutdown and full availability, and administrators use those intermediate states for maintenance. Oracle documents the sequence most explicitly, but every engine follows a similar path.

  1. Start: memory is allocated and background processes are launched, but no data files are open.
  2. Mount: the instance reads control or configuration metadata and locates the data and log files.
  3. Recover: committed changes missing from data files are reapplied from the log, and uncommitted ones are rolled back.
  4. Open: the database becomes available to client sessions for reads and writes.
  5. Shutdown: sessions are ended, dirty buffers are written to disk and memory is released.

Shutdown modes matter for recovery time. A clean shutdown writes all modified pages and leaves nothing to recover, while an immediate or abort shutdown is faster but forces crash recovery at the next start, which can take from seconds to many minutes depending on the volume of log since the last checkpoint.

Running several instances on one server

A single host can run multiple instances side by side, each with its own port, memory allocation and data directory. Teams do this to separate environments, to run different engine versions, or to apply independent security and patch schedules to different applications.

The trade-off is resource contention: instances do not coordinate memory with each other, so the sum of their configured caches must fit in physical RAM with room for the operating system. Overcommitting memory leads to swapping, which can degrade database performance by an order of magnitude or more.

SituationRecommended choiceReason
Many small internal applicationsOne instance, several databasesLower memory overhead, simpler patching
Different engine versions requiredSeparate instancesEach version needs its own binaries
Strict tenant isolationSeparate instances or serversIndependent failure, security and resources
Heavy and light workloads mixedSeparate instances with fixed memoryPrevents one workload starving another
High availability neededPrimary and standby instancesStandby takes over on failure
Choosing between one shared instance and separate instances

Common misconceptions about database instances

Several recurring misunderstandings come from treating instance and database as synonyms. Clearing them up helps when reading documentation, sizing servers or diagnosing outages.

  • Stopping an instance deletes data: it does not; data files persist, and only memory contents are released.
  • One server equals one instance: a host may run several instances, and a cluster may run one database across several hosts.
  • Restarting fixes performance permanently: a restart empties the buffer cache, so performance is often worse until the cache warms up again.
  • Instance settings apply per database: most memory and process parameters apply to the whole instance and every database it serves.
  • A replica is a backup: a standby instance replicates mistakes such as dropped tables almost immediately, so separate backups remain necessary.

A database administrator therefore monitors the instance through memory hit ratios, active sessions, wait events and log throughput, while monitoring the database through schema size, object growth and data integrity.

In simple terms

Think of a library. The books on the shelves are the database: they stay there even when the building is closed. The database instance is the staff on duty, with their desks, catalogs and carts, helping visitors find and return books.

When the library closes, the staff go home, but the books remain. When it reopens, the staff come back and continue the work. In the same way, turning an instance off does not erase the data; it only stops the service that lets people use it.

A practical example

A mid-sized online retailer runs its order system on a server with 64 GB of RAM. Originally the order database, a reporting database and a test database all shared one PostgreSQL instance. Every evening, large reporting queries pushed order data out of the shared buffers, and checkout response times rose from about 80 milliseconds to over 400 milliseconds.

The database team moved reporting to a separate instance on a different port with its own 12 GB memory limit and kept 24 GB of shared buffers for the order instance. The test database moved to another host. After the change, evening checkout latency returned to under 100 milliseconds, and the reporting instance could be restarted for upgrades without interrupting customer orders.