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 6242E53483 for ; Fri, 25 Mar 2005 02:55:08 +0000 (GMT) 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 53512-07 for ; Fri, 25 Mar 2005 02:55:04 +0000 (GMT) Received: from mailgate2.nau.edu (mailgate2.nau.edu [134.114.96.59]) by svr1.postgresql.org (Postfix) with ESMTP id 1BA055371D for ; Fri, 25 Mar 2005 02:55:03 +0000 (GMT) Received: from CONVERSION-DAEMON.mailgate2.nau.edu by mailgate2.nau.edu (PMDF V6.2-X17 #30770) id <0IDW0010103VSV@mailgate2.nau.edu> for pgsql-performance@postgresql.org; Thu, 24 Mar 2005 19:55:07 -0700 (MST) Received: from k2.cet.nau.edu (net9-213.cet.nau.edu [134.114.9.213]) by mailgate2.nau.edu (PMDF V6.2-X17 #30770) with ESMTP id <0IDW00HA803U8C@mailgate2.nau.edu>; Thu, 24 Mar 2005 19:55:06 -0700 (MST) Date: Thu, 24 Mar 2005 19:58:40 -0700 From: Karim Nassar Subject: Re: Delete query takes exorbitant amount of time In-reply-to: <3750.1111715318@sss.pgh.pa.us> To: Tom Lane Cc: pgsql-performance@postgresql.org Message-id: <1111719520.9085.190.camel@k2.cet.nau.edu> MIME-version: 1.0 X-Mailer: Evolution 2.0.2 Content-type: text/plain Content-transfer-encoding: 7BIT References: <1111709457.9085.127.camel@k2.cet.nau.edu> <2630.1111711927@sss.pgh.pa.us> <1111715131.9085.174.camel@k2.cet.nau.edu> <3750.1111715318@sss.pgh.pa.us> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200503/593 X-Sequence-Number: 11298 On Thu, 2005-03-24 at 20:48 -0500, Tom Lane wrote: > In that case there's a datatype mismatch between the referencing and > referenced columns, which prevents the index from being used for the > FK check. Can I have more words on this? Here is how I created the tables: CREATE TABLE int_sensor_meas_type( id_int_sensor_meas_type SERIAL PRIMARY KEY, id_sensor integer NOT NULL REFERENCES sensor, id_meas_type integer NOT NULL REFERENCES meas_type UNIQUE); CREATE TABLE measurement ( id_measurement SERIAL PRIMARY KEY, id_int_sensor_meas_type integer NOT NULL REFERENCES int_sensor_meas_type, datetime timestamp WITH TIME ZONE NOT NULL, value numeric(15,5) NOT NULL, created timestamp with time zone NOT NULL DEFAULT now(), created_by TEXT NOT NULL REFERENCES public.person(id_person)); CREATE INDEX measurement__id_int_sensor_meas_type_idx ON measurement(id_int_sensor_meas_type); Do I need to cast the id_int_sensor_meas_type column when creating the index? Both referrer and referenced look like INTEGER to me... http://www.postgresql.org/docs/8.0/interactive/datatype.html#DATATYPE-SERIAL says: "The type names serial and serial4 are equivalent: both create integer columns" TIA, -- Karim Nassar Department of Computer Science Box 15600, College of Engineering and Natural Sciences Northern Arizona University, Flagstaff, Arizona 86011 Office: (928) 523-5868 -=- Mobile: (928) 699-9221