Non clustered primary key on MySQL

This is a discussion on Non clustered primary key on MySQL within the MySQL Database forums, part of the Database Forums category; Hi: We have an application in our company and we use 32 byte keys, generated from hibernate, being used as ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-12-2008
raviaw
 
Posts: n/a
Default Non clustered primary key on MySQL

Hi:
We have an application in our company and we use 32 byte keys,
generated from hibernate, being used as primary keys in our MySQL
database. As these are the primary keys for MySQL, they also become
the clustered index for the table for which they belong to. I don't
have any other field that I would like to use as clustered key, and I
don't want to create an auto increment field just for that.

In resume: is there anyway to DISABLE MySQL from creating a clustered
index and to make it order the records in the same order as they're
inserted in the database? I know SQL Server does that and I was hoping
MySQL would do the same.

Regards, Ravi.
Reply With Quote
  #2 (permalink)  
Old 05-12-2008
Axel Schwenke
 
Posts: n/a
Default Re: Non clustered primary key on MySQL

raviaw <raviaw@gmail.com> wrote:

> We have an application in our company and we use 32 byte keys,
> generated from hibernate, being used as primary keys in our MySQL
> database. As these are the primary keys for MySQL, they also become
> the clustered index for the table for which they belong to.


This is only true for InnoDB tables. In the following I assume that
we are talking about InnoDB tables.

> In resume: is there anyway to DISABLE MySQL from creating a clustered
> index and to make it order the records in the same order as they're
> inserted in the database?


You will get something along that if you do not specify a PRIMARY KEY
in the table definition. Your former primary key becomes a UNIQUE KEY.

With no primary key in the table definition, InnoDB will create a
hidden primary key very similar to BIGINT UNSIGNED AUTO_INCREMENT
and use it internally to identify rows. Rows will be clustered
according to this hidden column and secondary indexes will refer
to rows via that hidden column too.


HTH, XL
--
Axel Schwenke, MySQL Support Engineer, Sun Microsystems GmbH

MySQL User Manual: http://dev.mysql.com/doc/refman/5.0/en/
MySQL User Forums: http://forums.mysql.com/
Reply With Quote
  #3 (permalink)  
Old 05-13-2008
raviaw
 
Posts: n/a
Default Re: Non clustered primary key on MySQL

On May 12, 4:28 pm, Axel Schwenke <axel.schwe...@gmx.de> wrote:
> raviaw <rav...@gmail.com> wrote:
> > We have an application in our company and we use 32 byte keys,
> > generated from hibernate, being used as primary keys in our MySQL
> > database. As these are the primary keys for MySQL, they also become
> > the clustered index for the table for which they belong to.

>
> This is only true for InnoDB tables. In the following I assume that
> we are talking about InnoDB tables.
>
> > In resume: is there anyway to DISABLE MySQL from creating a clustered
> > index and to make it order the records in the same order as they're
> > inserted in the database?

>
> You will get something along that if you do not specify a PRIMARY KEY
> in the table definition. Your former primary key becomes a UNIQUE KEY.
>
> With no primary key in the table definition, InnoDB will create a
> hidden primary key very similar to BIGINT UNSIGNED AUTO_INCREMENT
> and use it internally to identify rows. Rows will be clustered
> according to this hidden column and secondary indexes will refer
> to rows via that hidden column too.
>
> HTH, XL
> --
> Axel Schwenke, MySQL Support Engineer, Sun Microsystems GmbH
>
> MySQL User Manual:http://dev.mysql.com/doc/refman/5.0/en/
> MySQL User Forums:http://forums.mysql.com/


Great, that is what I was looking for. Thanks!
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 01:56 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0