from: http://dev.mysql.com/doc/refman/5.1/en/innodb-auto-increment-handling.html

If you specify an AUTO_INCREMENT column for an InnoDB table, the table handle 
in the InnoDB data dictionary contains a special counter called the 
auto-increment counter that is used in assigning new values for the column. 
This counter is stored only in main memory, not on disk. 
InnoDB uses the following algorithm to initialize the auto-increment counter 
for a table t that contains an AUTO_INCREMENT column named ai_col: After a 
server startup, for the first insert into a table t, InnoDB executes the 
equivalent of this statement: 
SELECT MAX(ai_col) FROM t FOR UPDATE;
InnoDB increments by one the value retrieved by the statement and assigns it to 
the column and to the auto-increment counter for the table. If the table is 
empty, InnoDB uses the value 1. If a user invokes a SHOW TABLE STATUS statement 
that displays output for the table t and the auto-increment counter has not 
been initialized, InnoDB initializes but does not increment the value and 
stores it for use by later inserts. This initialization uses a normal 
exclusive-locking read on the table and the lock lasts to the end of the 
transaction

kebetulan pernah ketemu masalah yang sama,  solusinya di level aplikasi om.. 
sedikit repot dari MyISAM 




________________________________
From: k_wahyoedi <[email protected]>
To: [email protected]
Sent: Mon, December 14, 2009 1:18:42 PM
Subject: Re: Bls: [ MiteK-L ] InnoDB-MySQL autoincrement

  
--- In mi...@yahoogroups. com, bhlukutuq AMD <bhluku...@. ..> wrote:
>
> Kalau yang dimaksud adalah : 
> - ID itu bukan dari Field Autoincrement
> - Namun sbg penanda yg unik
> - Bisa terus berurutan walopun ada record yg didelete dimanapun letaknya, yg 
>   berarti kalo ada pendeletan dan di INSERT lagi maka mengisi lagi ID
>   pada record yg didelete tersebut. Sehingga tidak ada ID yang gowang 
> (melompat)
> 

Solusi sampeyan mak-nyus, cuman bukan solusi yg tepat buat masalah saya.
Asset ID adalah nomor asset, sesuai dengan sifat asset maka saya perlakukan sbb 
:

- Asset ID harus unik
- Tidak ada proses delete Asset ID, kenapa ?? ya karena dibutuhkan
untuk proses audit dsb-nya. 
- Make autoincrement, di kepala saya harusnya bisa menggampangkan 
kita koding, sesuai dg 2 item perlakuan di atas
- Di relasikan di level database.. biar enak, ndak mumet di koding-nya.
- Make innodb, ya karena katanya tipe itu yg suppor relational di MySQL.
- Kenapa gak pake postgre ?? ya pada waktu itu gak kepikiran he..he

Masalah :
- Autoincrement kadang lompat (belum pernah terjadi ketika saya pake MyISAM)
Lompatnya itu juga tidak mempunyai pola tertentu, jadi agak bingung
apakah errornya dari level aplikasi atau level database.
- Masalah lompat ID sebenarnya tidak masalah karena ID tetap unik,
menjadi bermasalah ketika di proses Insert eksekusi dinyatakan 
berhasil. Hilangnya ID hanya diketahui ketika user logout dari
aplikasi. Prosesnya mirip proses insert (transaksi) tapi belum
di-commit.

Solusi :
- Sementara dicoba pake Bulk Insert --> lumayan berkurang frekuensi-nya.
- Sedang dicoba pake transaction (BEGIN.. COMMIT)-->belum dicobain.

mbaca-mbaca di internet sepertinya belum nemu solusi yg tepat.

matur nuwun
Kurnia_1


 


      

[Non-text portions of this message have been removed]

Kirim email ke