ashitaka
ashitaka

Reputation: 3918

Are Concurrent SQL inserts into the same table transactionally safe?

I have a simple table in MySql whose raison-d'être is to store logs. The table has an autoincremented sequence and all the other columns has zero referential integrity to other tables. There are no unique keys or indexes on any columns. The column with autoincrement is the primary key.

Will concurrent INSERTs ever interfere with each other ? I define interference to mean losing data.

I am using autocommit=true for this insert.

Upvotes: 1

Views: 1023

Answers (3)

Ask Bjørn Hansen
Ask Bjørn Hansen

Reputation: 6943

You'll never lose data just because you do simultaneous inserts. If you use transactions you might "lose" some IDs - but no actual data. (Imagine that you start a transaction, insert a few rows and then do a rollback. InnoDB will have allocated the auto_increment IDs , but there are no rows with those IDs because you did the rollback).

Since you don't need indexes, you should have a look at the ARCHIVE table engine. It's amazingly insanely fast -- and your tables gets much smaller which in turn makes the table scans when you read the table later MUCH faster.

Upvotes: 3

David Grant
David Grant

Reputation: 14225

From the MySQL manual for the MyISAM storage engine:

"MyISAM supports concurrent inserts..."

Upvotes: 2

Learning
Learning

Reputation: 8175

Yes. For InnoDB , more information here

Upvotes: 2

Related Questions