From: Alexander Priem <ap@cict.nl>
To: Tomasz Myrta <jasiek@klaster.net>
Cc: pgsql-performance@postgresql.org
Subject: Re: Indexing question
Date: Fri, 29 Aug 2003 11:08:21 +0200
Message-ID: <01bf01c36e0d$18769280$b696a8c0@APR> (raw)
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>
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" <jasiek@klaster.net>
To: "Alexander Priem" <ap@cict.nl>
Cc: <pgsql-performance@postgresql.org>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: ap@cict.nl, jasiek@klaster.net
Subject: Re: Indexing question
In-Reply-To: <01bf01c36e0d$18769280$b696a8c0@APR>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox