Possible Duplicate:
Why does MySQL autoincrement increase on failed inserts?
I have a table
CREATE TABLE `authors` (
`author_id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8_unicode_ci,
PRIMARY KEY (`id`),
UNIQUE KEY `name_UNIQUE` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
which I use to collect names of authors. I use oursql to populate this table. The query is
query_author ="""INSERT INTO authors (name) VALUES (?) ON DUPLICATE KEY UPDATE author_id=LAST_INSERT_ID(author_id)"""
and I execute it like this:
cursor.execute(query_author, (author,))
author_id = cursor.lastrowid # further using of the authors id.
Now I observe, that the auto increment does not always increment author_id
by 1. It jumps. In the 1000-th row I have the index 1258. I doublechecked my script, but this is the only passage where I modify the table authors
. What could possibly affect this behaviour? Some settings in my.cnf I don't know about? I am clueless with this.