Can one turn off constraints/indices temporarily? - Mailing list pgsql-novice

From
Subject Can one turn off constraints/indices temporarily?
Date
Msg-id 200602021449.k12EnBi20504@panix3.panix.com
Whole thread Raw
Responses Re: Can one turn off constraints/indices temporarily?
List pgsql-novice


I'm sorry if this question is very naive.  I'm very green at this.

When I read the SQL code generated by pg_dump, I notice that all the
constraints and indices are defined after all the data has been
inserted.  I figure this makes the bulk transfers much faster, since
each insert can happen without the need to check constraints and/or
update indices each time.

Now, suppose that one had to insert many records at once.  Is it
possible to mimic the above strategy by turning off the constraints
and indexing temporarily (without dropping them altogether), and
turning them back on after all the inserts have been made.  (Of
course, upon turning it back on, constraints would have to be checked
and indices would need to be updated, therefore one would repay the
"time debt", but hopefully this would still be smaller than doing all
this after each insert.)

Thanks!

kj

pgsql-novice by date:

Previous
From: George Tichogiorgos
Date:
Subject: prob in accessing psql at all
Next
From: Tom Lane
Date:
Subject: Re: Can one turn off constraints/indices temporarily?