Unix Technical Forum

Disable duplicate index creation

This is a discussion on Disable duplicate index creation within the Pgsql General forums, part of the PostgreSQL category; --> PostgreSQL runs commands create table test ( test integer primary key ); create index i1 on test(test); create index ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql General

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-09-2008, 05:53 PM
Andrus
 
Posts: n/a
Default Disable duplicate index creation

PostgreSQL runs commands

create table test ( test integer primary key );
create index i1 on test(test);
create index i2 on test(test);

without any error.
Now there are 3 same indexes on table.

How to fix this so that duplicate indexes are not allowed ?


Andrus.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-09-2008, 05:54 PM
Tom Lane
 
Posts: n/a
Default Re: Disable duplicate index creation

"Andrus" <kobruleht2@hot.ee> writes:
> PostgreSQL runs commands
> create table test ( test integer primary key );
> create index i1 on test(test);
> create index i2 on test(test);


> without any error.
> Now there are 3 same indexes on table.


> How to fix this so that duplicate indexes are not allowed ?


Simple: don't do that.

Having the system try to prevent this has been proposed, and rejected,
before. The main argument against has been that it'd prevent some
occasionally-useful procedures. Instead of REINDEX, which locks out
use of the index (for a long time, if table is big), you can make a new
index in parallel with CREATE INDEX CONCURRENTLY, and then drop the old
index, and not deny service to any query for very long. Another
objection is that it's not always clear which indexes are redundant ---
eg, should we forbid indexes on both (a,b) and (b,a)? In your above
example the indexes aren't even really identical --- the pkey one is
unique and the others not.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:25 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com