X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 50D0952856 for ; Mon, 30 May 2005 19:00:49 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 82915-03 for ; Mon, 30 May 2005 22:00:42 +0000 (GMT) Received: from presinet-main.presinet.com (presinet.com [209.53.156.1]) by svr1.postgresql.org (Postfix) with ESMTP id 84BF752806 for ; Mon, 30 May 2005 19:00:38 -0300 (ADT) Received: from [10.10.1.151] (BRICK [10.10.1.151]) by presinet-main.presinet.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2658.3) id L9MTJ0HM; Mon, 30 May 2005 14:57:08 -0700 Message-ID: <429B8D05.5040705@PresiNET.com> Date: Mon, 30 May 2005 15:00:37 -0700 From: Bricklen Anderson User-Agent: Debian Thunderbird 1.0.2 (X11/20050331) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Colton A Smith Cc: pgsql-performance@postgresql.org Subject: Re: poor performance involving a small table References: In-Reply-To: Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.02 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/447 X-Sequence-Number: 12611 Colton A Smith wrote: > > Hi: > > I have a table called sensors: > > Table "public.sensor" > Column | Type | Modifiers > -----------------+--------------------------+------------------------------------------------- > > sensor_id | integer | not null default > nextval('sensor_id_seq'::text) > sensor_model_id | integer | not null > serial_number | character varying(50) | not null > purchase_date | timestamp with time zone | not null > variable_id | integer | not null > datalink_id | integer | not null > commentary | text | > Indexes: > "sensor_pkey" PRIMARY KEY, btree (sensor_id) > Foreign-key constraints: > "datalink_id_exists" FOREIGN KEY (datalink_id) REFERENCES > datalink(datalink_id) ON DELETE RESTRICT > "sensor_model_id_exists" FOREIGN KEY (sensor_model_id) REFERENCES > sensor_model(sensor_model_id) ON DELETE RESTRICT > "variable_id_exists" FOREIGN KEY (variable_id) REFERENCES > variable(variable_id) ON DELETE RESTRICT > > > Currently, it has only 19 rows. But when I try to delete a row, it takes > forever. I tried restarting the server. I tried a full vacuum to no > avail. I tried the following: > > explain analyze delete from sensor where sensor_id = 12; > QUERY PLAN > ------------------------------------------------------------------------------------------------ > > Seq Scan on sensor (cost=0.00..1.25 rows=1 width=6) (actual > time=0.055..0.068 rows=1 loops=1) > Filter: (sensor_id = 12) > Total runtime: 801641.333 ms > (3 rows) > > Can anybody help me out? Thanks so much! > I'd say the obvious issue would be your foreign keys slowing things down. Have you analyzed the referenced tables, and indexed the columns on the referenced tables? -- _______________________________ This e-mail may be privileged and/or confidential, and the sender does not waive any related rights and obligations. Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized. If you received this e-mail in error, please advise me (by return e-mail or otherwise) immediately. _______________________________