Index/Foreign Key Question

From: "David Busby" <busby(at)pnts(dot)com>
To: <pgsql-general(at)postgresql(dot)org>, <pgsql-performance(at)postgresql(dot)org>
Subject: Index/Foreign Key Question
Date: 2003-10-10 21:04:51
Message-ID: 006a01c38f72$25461720$1100000a@busbydev
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-performance

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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joe Conway 2003-10-10 21:07:51 Re: Table partitioning for maximum speed?
Previous Message Joe Conway 2003-10-10 21:01:56 Re: Table partitioning for maximum speed?

Browse pgsql-performance by date

  From Date Subject
Next Message Vivek Khera 2003-10-10 21:14:25 Re: go for a script! / ex: PostgreSQL vs. MySQL
Previous Message Relaxin 2003-10-10 21:03:51 Re: One or more processor ?