X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.192]) by svr1.postgresql.org (Postfix) with ESMTP id 67516CC9B4 for ; Thu, 17 Jul 2003 18:51:43 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr4.postgresql.org [64.117.224.192]) (amavisd-new, port 10024) with ESMTP id 48433-01 for ; Thu, 17 Jul 2003 18:52:11 +0000 (GMT) Received: from anchor-post-35.mail.demon.net (anchor-post-35.mail.demon.net [194.217.242.85]) by svr1.postgresql.org (Postfix) with ESMTP id E0A06CC9B3 for ; Thu, 17 Jul 2003 15:51:41 -0300 (ADT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-35.mail.demon.net with esmtp (Exim 3.36 #2) id 19dDrP-0006aF-0Z; Thu, 17 Jul 2003 19:52:11 +0100 Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id 4E9F116A59; Thu, 17 Jul 2003 19:52:10 +0100 (BST) Received: from client.archonet.com (client.archonet.com [192.168.1.16]) by mainbox.archonet.com (Postfix) with ESMTP id A0D4616988; Thu, 17 Jul 2003 19:52:09 +0100 (BST) Content-Type: text/plain; charset="iso-8859-1" From: Richard Huxton Organization: Archonet Ltd To: "Girish Bajaj" , Subject: Re: Table Partitioning and Rules Date: Thu, 17 Jul 2003 19:52:07 +0100 User-Agent: KMail/1.4.3 References: <002f01c34c87$a72f59a0$7764a8c0@tietronix.com> In-Reply-To: <002f01c34c87$a72f59a0$7764a8c0@tietronix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200307171952.07485.dev@archonet.com> X-Virus-Scanned: by AMaViS snapshot-20020531 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/234 X-Sequence-Number: 14348 On Thursday 17 Jul 2003 6:20 pm, Girish Bajaj wrote: > Hello All, > > I have a set of tables partitioned horizontally. DML below. > > Essentially Im trying to store a persons information in a table in the > database. Since we could have millions of people, with duplicates! Ive > decided we need to partition the table into segments where all people with > the LastName starting from A to G will be in one table. H-N will be in > another table and O-Z in the third. Ive created a VIEW that does a UNION = on > all the tables. I'd not bother - databases are good at managing large amounts of informatio= n.=20 If you really need to you can set up multiple partial indexes: CREATE INDEX my_index_a ON contact (LastName) WHERE LastName>=3D'A' AND=20 LastName<'B' CREATE INDEX my_index_b ON contact (LastName) WHERE LastName>=3D'B' AND=20 LastName<'C' etc. > Now, Im trying to create an INSERT and UPDATE RULE on the VIEW that would > direct an insert or update into the appropriate partition table depending > on the person LastName. > > I cant seem to figure this out. Does anyone know how to do this? Something like: CREATE RULE ... ON INSERT TO Contact WHERE NEW.LastName>=3D'A' AND=20 NEW.LastName<'H' DO INSTEAD ...insert into correct table here... You'll want to read the chapter on the rule system in the "Server Programmi= ng"=20 section of the manual. --=20 Richard Huxton