Skip to main content

DBLab vs CREATE DATABASE ... TEMPLATE

thin clones vs in-server copies

CREATE DATABASE ... TEMPLATE copies a database inside the same PostgreSQL server, built in and free. DBLab makes thin clones of a full database on its own machine.

See how DBLab worksOpen the demoPricing

Checked on against 6 pages of CREATE DATABASE ... TEMPLATE documentation. PostgreSQL only. Markdown

Where DBLab is ahead of CREATE DATABASE ... TEMPLATE​

Each point pairs what our documentation says with what the CREATE DATABASE ... TEMPLATE documentation says. Follow the links and check.

  1. Clones the Postgres you already run

    DBLab

    Any PostgreSQL from version 10 up, wherever it runs: Amazon RDS, Aurora, Cloud SQL, Supabase or your own servers. docsdocs 2

    CREATE DATABASE ... TEMPLATE

    CREATE DATABASE ... TEMPLATE copies a database into the same PostgreSQL cluster. No other session may be connected to the template while it is copied, and the docs say it is not yet intended as a general-purpose COPY DATABASE facility. 12

  2. One copy of the data, many clones

    DBLab

    Clones share one physical copy on one machine and take extra disk space only for what they change. DBLab SE is billed by the size of that machine, not by database size or number of clones. docsdocs 2

    CREATE DATABASE ... TEMPLATE

    With the default WAL_LOG strategy, the copy writes every block again and to WAL, in the same server. With FILE_COPY and file_copy_method = clone (PostgreSQL 18), the kernel may share disk blocks on some file systems. 13

  3. Catches a dangerous migration in CI

    DBLab

    DB Migration Checker runs pending migrations on a clone in CI and fails those that hold dangerous locks longer than a limit, 10 seconds by default. docs

    CREATE DATABASE ... TEMPLATE

    A CI job can run CREATE DATABASE ... TEMPLATE or createdb -T while no other session is connected to the template. The sources we reviewed do not describe running migrations on the copy or checking the locks they take. 15

Short answer​

CREATE DATABASE with TEMPLATE copies one database into a new database in the same PostgreSQL server. It is built in, and in PostgreSQL 18 STRATEGY FILE_COPY with file_copy_method = clone lets the kernel share disk blocks on file systems that support it. The docs say it is not yet intended as a general-purpose COPY DATABASE facility: no other session may be connected to the source while it is copied, and the copy lives in the same server. DBLab makes thin clones on its own machine, each an ordinary PostgreSQL server. To copy a database that nobody is connected to, such as a test fixture, the built-in command needs nothing else.

When CREATE DATABASE ... TEMPLATE is the better choice​

  • Built into every PostgreSQL server: one SQL command, or createdb -T, with no extra software, machine or license.
  • You can make your own template databases: mark one with IS_TEMPLATE and any user with the CREATEDB privilege can copy it.
  • Objects added to a template are in every copy. The docs give the example of a procedural language installed in template1 being available in every new database.
  • In PostgreSQL 18, STRATEGY FILE_COPY with file_copy_method = clone uses copy_file_range() on Linux and FreeBSD or copyfile on macOS, so the kernel can share disk blocks on some file systems.
  • The copy is an ordinary database in the server you already run, with no second server to start, connect to or pay for.
The DBLab UI showing a clone that is ready to accept Postgres connections, created in 1.67 seconds, with its psql connection string.

What you get​

A clone in the DBLab UI, ready for connections 1.67 seconds after it was requested (a 2.7 GiB demo database). How it works

See how DBLab worksOpen the demoPricing

DBLab and CREATE DATABASE ... TEMPLATE, side by side​

QuestionDBLabCREATE DATABASE ... TEMPLATE
What it isOpen-source software that gives every developer, CI job and AI agent a writable, full-size copy of a PostgreSQL database in seconds. Thin clones share one physical copy of the data on one machine. docsdocs 2A built-in SQL command. CREATE DATABASE works by copying an existing database, template1 by default; TEMPLATE name copies another database in the same cluster. The docs say this is "not (yet) intended as a general-purpose 'COPY DATABASE' facility." 12
Which databases it can copyYesAny PostgreSQL from version 10 up, wherever it runs. Managed services such as Amazon RDS, Aurora, Cloud SQL and Supabase are copied with dump and restore; self-managed servers can also be copied physically with WAL-G, pgBackRest or pg_basebackup. docsdocs 2PartlyAny database in the same PostgreSQL cluster, on any server where you may create databases. Any user with CREATEDB can copy a database marked as a template; otherwise only superusers and the owner can. Source and copy are in the same cluster. 12
How a copy is madeCopy-on-write in the file system, with ZFS or LVM. Clones share unchanged blocks, so a clone takes extra disk space only for what it changes. docsWAL_LOG, the default, copies block by block and writes each block to WAL. FILE_COPY copies directories at file system level, with a checkpoint before and after. In PostgreSQL 18, file_copy_method = clone makes FILE_COPY use copy_file_range() (Linux, FreeBSD) or copyfile (macOS), letting the kernel share disk blocks on some file systems. 134
Time to get a copyA few seconds whatever the database size: under 2 seconds for a 10 TiB database with one user, up to 30 seconds with 15 users at once. The first copy of the source is slow; about 1 TiB an hour is a good speed. docsdocs 2The docs give no times. WAL_LOG is described as the most efficient strategy when the template is small. FILE_COPY reduces WAL volume for a large template but forces two checkpoints. Whether clone shares blocks depends on the file system; the docs do not name which ones do. 13
Data in a copyYesThe whole database as of the chosen snapshot. Physical mode can follow the source continuously; logical mode is refreshed in full, on a schedule. docsdocs 2YesThe whole source database. Database-level settings (set with ALTER DATABASE) and database-level GRANT permissions are not copied. Encoding and locale must match the template, except when template0 is used. 12
Masking sensitive dataYesDocumented options: load an anonymized dump, or apply SQL transformations or PostgreSQL Anonymizer before snapshots are taken. You define the rules. docsNot documentedNot documented in the sources we reviewed. CREATE DATABASE copies the template database as it is. 12
CI and migration testingYesDB Migration Checker runs pending migrations on a clone in CI, fails those that hold dangerous locks longer than a limit (10 seconds by default) and collects statistics. Any CI job can also create clones through the API or CLI. docsPartlyNo CI feature is documented. A CI job can run CREATE DATABASE ... TEMPLATE or createdb -T, as long as no other session is connected to the template at that moment. 15
API, CLI and agent accessREST API, web UI and the dblab CLI. Joe, also available as pgai joe, returns EXPLAIN plans and timings from a clone, not rows. docsdocs 2docs 3SQL: CREATE DATABASE with TEMPLATE, STRATEGY and IS_TEMPLATE. The createdb program connects to the postgres database and issues the same command. 15
Where it runsYesOn a machine you control, in any cloud or on-premises. DBLab SE installs from the PostgresAI Console or AWS Marketplace. docsdocs 2YesInside the PostgreSQL server that holds the source. The new database is in the same cluster, served by the same server; the docs warn that FILE_COPY's checkpoints may have a noticeable negative impact on overall system performance. 12
Open sourceYesDBLab Engine is open source under Apache 2.0. docsYesPart of PostgreSQL, released under the PostgreSQL License, which the project describes as a liberal open-source license similar to BSD or MIT. 6
Documented limitsDBLab SE: 2,000 GiB per instance and a single user. All clones share one machine, and copy-on-write storage has different I/O performance, so timings on a clone should not be compared directly with production. docsdocs 2No other session may be connected to the template: CREATE DATABASE fails if one is, and new connections to it are blocked until the copy completes. Encoding and locale must match (except for template0). Database-level settings and GRANTs are not copied. file_copy_method = clone needs operating system support. 123
What you pay forOne machine and one physical copy of the data, however many clones run. DBLab SE is billed hourly by the size of that machine, not by database size or number of clones. docsFree, part of PostgreSQL. Copies use disk in the same server: WAL_LOG writes each block again and to WAL. With FILE_COPY and file_copy_method = clone, the kernel may share blocks on file systems that support it. 136

Pricing​

ProductPlanList priceNotes
DBLabDBLab EngineFreeOpen source, Apache 2.0; you run it
DBLabDBLab SEFrom $62/monthBilled hourly by machine size, plus your own cloud costs; 2,000 GiB limit; single user
DBLabDBLab EECustomAnnual contract, from $0.2662 per 100 GiB per hour; unlimited database size, SSO
CREATE DATABASE ... TEMPLATEOpen sourceFreePart of PostgreSQL, PostgreSQL License 6

List prices on 18 Nov 2026. The billing units differ, so this is not a total-cost comparison. DBLab pricing

Questions​

Can I copy a production database with CREATE DATABASE ... TEMPLATE?
Only when no other session is connected to it. CREATE DATABASE fails if any other connection exists when it starts, and new connections to the source are blocked during the copy. The docs say this is not yet intended as a general-purpose COPY DATABASE facility. The copy also lives in the same server as the source. 12
What does file_copy_method = clone do in PostgreSQL 18?
It changes how CREATE DATABASE ... STRATEGY=FILE_COPY and ALTER DATABASE ... SET TABLESPACE copy files. The default is COPY. CLONE uses copy_file_range() on Linux and FreeBSD or copyfile on macOS, giving the kernel the opportunity to share disk blocks. The setting was added in PostgreSQL 18. 34
Which file systems support cloning with file_copy_method?
The PostgreSQL docs do not name any. They say CLONE uses copy_file_range() or copyfile, "giving the kernel the opportunity to share disk blocks or push work down to lower layers on some file systems." Check your file system's own documentation. 3
Who can copy a database with TEMPLATE?
Creating a database needs superuser or the CREATEDB privilege. If the source is marked as a template (IS_TEMPLATE, datistemplate), any user with CREATEDB can copy it; if not, only superusers and the owner of the database can. 12
How is DBLab different from a template copy?
A template copy is a new database in the same server as its source. DBLab copies any PostgreSQL from version 10 up, including Amazon RDS, onto its own machine, then makes thin clones of that copy; each clone is an ordinary PostgreSQL server. 12

Try a clone before you install anything​

The public demo runs DBLab Engine: open it with the token demo-token, create a clone and connect to it. DBLab Engine is open source, so the next step is a machine of your own.

See how DBLab worksOpen the demoPricing

Sources​

  1. PostgreSQL docs: CREATE DATABASE
  2. PostgreSQL docs: Template Databases
  3. PostgreSQL docs: file_copy_method
  4. PostgreSQL 18 docs: Release 18
  5. PostgreSQL docs: Creating a Database
  6. PostgreSQL License

These pages compare what each product does for PostgreSQL; other databases and the rest of the stack are out of scope. What we say about the other product comes from its own documentation, pricing page, changelog or source repository, read on the date shown; each row cites its source. "Not documented" means we did not find it in those sources, not that the product cannot do it. Prices are list prices and the billing units differ, so they are not a total-cost comparison. Product names are trademarks of their owners. Found a mistake? Tell us and we will correct the page.