X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 2F278D1B541; Fri, 10 Oct 2003 21:13:16 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 05652-05; Fri, 10 Oct 2003 18:12:32 -0300 (ADT) Received: from seapdc01.PNTS (ip63.c216.blk1.bel.nwlink.com [209.20.216.63]) by svr1.postgresql.org (Postfix) with ESMTP id 8BE8CD1B528; Fri, 10 Oct 2003 18:12:29 -0300 (ADT) Received: from busbydev (BUSBY-DEV [10.0.0.17]) by seapdc01.PNTS with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id TSH2QR5Q; Fri, 10 Oct 2003 14:31:55 -0700 Message-ID: <006a01c38f72$25461720$1100000a@busbydev> Reply-To: "David Busby" From: "David Busby" To: , Subject: Index/Foreign Key Question Date: Fri, 10 Oct 2003 14:04:51 -0700 Organization: Pacific Northwest Ticket Service MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests=BAYES_30, RCVD_IN_OSIRUSOFT_COM X-Spam-Level: X-Archive-Number: 200310/523 X-Sequence-Number: 50596 List, I'm creating this multi company POS database. My inventory table looks like (all items are unique): id,category_id,invoice_id,x,y,z,gid,uid I have a primary key on id, and then an foreign keys on category_id and invoice_id. GID is the group ID of the company, UID is the companies user, they are also connected via foreign key to the respective tables. My question is this: Do I need to create more indexes on this table when inventory selects look like select * from inventory where category_id = 1 and invoice_id is null and gid = 2 So where would the indexes need to be placed? Or since I have the FK setup are the indexes already in place? I expect to soon have >500K items in the inventory table and don't want it to slow down. I'll have the same type of issue with clients, invoices, purchase_orders and perhaps more Ideas? Thanks! David Busby Systems Engineer