X-Original-To: pgsql-performance-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 5930D9FB2D5 for ; Thu, 10 Aug 2006 05:05:42 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 31150-10 for ; Thu, 10 Aug 2006 08:05:37 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from nutty.inf.ed.ac.uk (nutty.inf.ed.ac.uk [129.215.216.3]) by postgresql.org (Postfix) with ESMTP id 603A39FB2BE for ; Thu, 10 Aug 2006 05:05:36 -0300 (ADT) Received: from [129.215.218.230] (skibo.inf.ed.ac.uk [129.215.218.230]) by nutty.inf.ed.ac.uk (8.13.6/8.13.6) with ESMTP id k7A85ZZa019279 for ; Thu, 10 Aug 2006 09:05:35 +0100 Message-ID: <44DAE8CF.1030107@inf.ed.ac.uk> Date: Thu, 10 Aug 2006 09:05:35 +0100 From: Sue Fitt User-Agent: Thunderbird 1.5.0.4 (X11/20060620) MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: setting up foreign keys Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.313 tagged_above=0 required=5 tests=SARE_MILLIONSOF, SPF_HELO_PASS, SPF_PASS X-Spam-Level: X-Archive-Number: 200608/176 X-Sequence-Number: 20361 Hi all, This is my first post to the performance list, I hope someone can help me. I'm setting up a table with 2 columns, both of which reference a column in another table: CREATE TABLE headwords_core_lexemes ( core_id int REFERENCES headwords_core(core_id), lexeme_id int REFERENCES headwords_core(core_id), ); Trouble is, it's taken 18 hours and counting! The table headwords_core only has about 13,000 lines, and core_id is the primary key on that table. However, I assume it must be those 13,000 lines that are the problem, since if I try it referencing a similar table with 360 lines the new table is created almost instantly. I found a post on a similar subject from quite a while ago, but no answer, and that was for millions of rows anyway. I only have 13,000. Surely it should be faster than this? Is there a way to speed it up? Sue Fitt