[rt-users] RT related Postgres question
Vivek Khera
vivek at khera.org
Mon Dec 3 14:54:46 EST 2007
>
> CREATE INDEX objectcustomfieldvalues1 ON objectcustomfieldvalues
> USING btree (customfield, objecttype, objectid, content);
> CREATE INDEX objectcustomfieldvalues2 ON objectcustomfieldvalues
> USING btree (customfield, objecttype, objectid);
The second index is redundant to the first. Depending on how the
indexes are used (ie, all columns, or just some subset), if you
reorder the columns, you can make the third index on this table
redundant too.
Similarly, your attachments1 index is redundant to attachments3. Also
depending on how tickets1 index gets used swapping the order and
removing tickets4 may be more efficient overall, as well.
In general, if you're index columns list is a prefix of another
index's, then it is a redundant index. This does not necessarily hold
true for UNIQUE indexes, but often they are good enough even then.
Ie, if the difference is within a percentage or two of time used, then
you benefit over time by having one fewer index to update on row
changes/inserts.
More information about the rt-users
mailing list