Search Postgresql Archives

Re: Very slow DELETEs with foreign keys

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thom Brown <thom@xxxxxxxxx> writes:
> I've just noticed a general delete performance issue while testing a
> patch, and this can be recreated on all recent major versions.

> I have 2 tables:

> CREATE TABLE countries (
>     country text PRIMARY KEY,
>     continent text
> );

> CREATE TABLE contacts (
>     id serial PRIMARY KEY,
>     first_name text,
>     last_name text,
>     age integer,
>     country text REFERENCES countries (country)
> );

Apparently, you don't have an index on the referencing column.
That makes insertions into contacts faster, at the cost of making
deletions from countries much slower.  Since there are cases where
that's a reasonable tradeoff, we don't prohibit you from omitting
the index ... but it is a pretty standard foot-gun.

			regards, tom lane


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux