Can one turn off constraints/indices temporarily?

From: <kynn(at)panix(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Can one turn off constraints/indices temporarily?
Date: 2006-02-02 14:49:11
Message-ID: 200602021449.k12EnBi20504@panix3.panix.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2006-02-02 14:57:12 Re: Can one turn off constraints/indices temporarily?
Previous Message Adam Witney 2006-02-02 12:51:18 Re: prob in accessing psql at all