On 2/14/17 2:49 PM, Pavel Stehule wrote:
> Tom's use case might be more easily served by specifying a
> template database. I don't think Pavel ever posted his use case.
Wait, that's precisely what Pavel asked?
I would to use regress test environment in my current case. 99% code in
plpgsql, but there is pretty complex schema. About 300 tables. 1k views.
2k functions. Import schema is slow. Database clonning is much faster.
FWIW, for actual production environments (which I assume this is), I
find pg_regress to be completely useless. Some simple shell scripts to
build the database (possibly using sqitch) and then a script around
pg_prove is what I normally use. https://github.com/BlueTreble/db_tools
gives you the general idea.
Speaking for myself, my normal pattern is to have a number of separate
pg_regress suites, each of which ends up loading the extension under test.
Loading a large extension can end up being very time consuming; enough so
that I'd expect it to be much faster to create the temp cluster, load all
the prereq's once in some template database, and then use that template for
most/all of the tests.
I seriously doubt that. CREATE DATABASE is ridiculously expensive,
copies everything on the file-level and requires checkpoints. If your
extension is more expensive than that, I'd say you're likely doing
That depends on the extension. pgTap for example contains over 900
functions. A quick test on my laptop shows it's faster to create a
database from a template containing the extension than it is to create
the extension itself.
decibel@decina:[12:33]~$time createdb t
decibel@decina:[12:34]~$time psql -c 'create extension pgtap' t
decibel@decina:[12:34]~$time createdb -T t t2
decibel@decina:[12:34]~$time psql -c 'drop extension pgtap' t
decibel@decina:[12:34]~$time dropdb t
decibel@decina:[12:34]~$time dropdb t2
Interestingly, CREATE EXTENSION is 2x faster than simply running the file:
decibel@decina:[12:38]~$time psql -qtf
decibel@decina:[12:41]~$(echo 'begin;'; echo "\i
$PGDATA/../share/extension/pgtap--0.97.0.sql"; echo 'commit;') | time
psql -qt t
1.12 real 0.04 user 0.02 sys
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com
Sent via pgsql-hackers mailing list (email@example.com)
To make changes to your subscription: