does index created automatically for primary key and unique constraints.

2,295 views
Skip to first unread message

vj

unread,
Sep 16, 2011, 10:33:37 AM9/16/11
to H2 Database
Hi,
i have 2 questions on this.
1) does H2 db, creates it's own indexes for primary key and unique
constraints, automatically?

2) if we also create our own indexes with different names for same
primary-key ,
will it still allow 2 indexes ( different names) for same primary
key,
if so, does search becomes little slow.. taking into consideration,
there are 2 indexes.. for same primary-key..

Thanks,
vj

Thomas Mueller

unread,
Sep 20, 2011, 2:09:43 AM9/20/11
to h2-da...@googlegroups.com
Hi,

1) does H2 db, creates it's own indexes for primary key and unique
constraints, automatically?

Yes.
 
2) if we also create our own indexes with different names for same
primary-key ,
will it still allow 2 indexes ( different names) for same primary
key,

Yes.
 
if so, does search becomes little slow..

No, search not. But inserting / updating / deleting rows will become slower, because additional indexes need to be maintained.

Regards,
Thomas

h2_mad

unread,
Jun 25, 2012, 9:22:22 AM6/25/12
to h2-da...@googlegroups.com
Hi,

In responce to this then:


"No, search not. But inserting / updating / deleting rows will become slower, because additional indexes need to be maintained."

how would i stop the auto-index creation when i've already explicitly created the same index?

thanks

m

h2_mad

unread,
Jun 25, 2012, 11:05:13 AM6/25/12
to h2-da...@googlegroups.com
nevermind - i found it:

"Hi,
>  Does H2 automatically create indices for foreign key constraints?

Yes: The required indexes are automatically created if required. I
will add this to the docs.

>  is it correct to assume that H2 will automatically create an index on
>  the bar_id column of the above table?  So the following statement
>  would be redundant:
>  create index foo_idx1 on foo(bar_id); ?

Yes. But if you create this index before creating the foreign key, it
will be used and no additional (system-) index will be created.

Regards,
Thomas"
Reply all
Reply to author
Forward
0 new messages