Skip to content

Instantly share code, notes, and snippets.

@jackdouglas
Created December 16, 2011 09:10
Show Gist options
  • Save jackdouglas/1485246 to your computer and use it in GitHub Desktop.
Save jackdouglas/1485246 to your computer and use it in GitHub Desktop.
Performance hit of a check constraint in Postgres
begin;
set role dba;
create role stack;
grant stack to dba;
create schema authorization stack;
set role stack;
--
create table foo(id integer check (id>0));
create table bar(id integer);
\timing on
insert into foo(id) select generate_series(1, 1000000);
insert into bar(id) select generate_series(1, 1000000);
\timing off
--
rollback;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment