X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 448B2D1B8E5 for ; Fri, 29 Aug 2003 09:07:02 +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 05293-05 for ; Fri, 29 Aug 2003 06:06:32 -0300 (ADT) Received: from mail.cict.nl (vnd-7521.mxs.adsl.euronet.nl [62.234.149.33]) by svr1.postgresql.org (Postfix) with ESMTP id 70D23D1B8D2 for ; Fri, 29 Aug 2003 06:06:29 -0300 (ADT) Received: from APR ([192.168.150.182]) by mail.cict.nl (Merak 6.0.5) with SMTP id DUC73886; Fri, 29 Aug 2003 11:06:28 +0200 Message-ID: <01bf01c36e0d$18769280$b696a8c0@APR> From: "Alexander Priem" To: "Tomasz Myrta" Cc: References: <012f01c36dfa$0f4a8760$b696a8c0@APR> <3F4EFAB6.7030104@klaster.net> <015f01c36e02$134fe960$b696a8c0@APR> <3F4F07CE.6090803@klaster.net> <018c01c36e09$4893e980$b696a8c0@APR> <3F4F1575.8090600@klaster.net> Subject: Re: Indexing question Date: Fri, 29 Aug 2003 11:08:21 +0200 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.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/486 X-Sequence-Number: 3302 The first index is for sorting on orad_id, the second one for sorting on orad_name. The first one would be useful for queries like 'select * from orderadvice_edit where orad_id=100', the second one for queries like 'select * from orderadvice_edit order by orad_name'. Right? Does anyone know whether it is bad practise to have two indexes on the primary key of a table? (one 'primary key' index and one partial index) ----- Original Message ----- From: "Tomasz Myrta" To: "Alexander Priem" Cc: Sent: Friday, August 29, 2003 10:57 AM Subject: Re: [PERFORM] Indexing question > > create index orad_id_index on orderadvice (orad_id) where orad_deleteddate > > is null; > > create index orad_name_index on orderadvice (orad_name) where > > orad_deleteddate is null; > > > > create view orderadvice_edit as select > > orad_id,orad_name,orad_description,orad_value,orad_value_quan from > > orderadvice where orad_deleteddate is null; > > > > Would queries like 'select * from orderadvice_edit where orad_id=100' or > > 'select * from orderadvice_edit order by orad_name' both use one of these > > two partial indexes, given enough records are present in the table? > > > > There would be a double index on the primary key this way, right? > > It looks much better now. I'm not sure about the second index. Probably > it will be useless, because you sort ALL records with deleteddtata is > null. Maybe the first index will be enough. > > I'm not sure what to do with doubled index on a primary key field. > > Regards, > Tomasz Myrta > > > ---------------------------(end of broadcast)--------------------------- > TIP 8: explain analyze is your friend