Mysql – In a simple table with no complex indexes, does a large number of existing rows slow down an INSERT

bulkinsertMySQL

I have this small, simple table:

CREATE TABLE `ads_tracker` (
  `id` int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
  `type` smallint unsigned NOT NULL,
  `reference` smallint unsigned NOT NULL,
  `date` timestamp NOT NULL,
  `action` enum('view','click') NOT NULL DEFAULT 'view'
) COMMENT='' ENGINE='InnoDB' COLLATE 'utf8_unicode_ci';

It has only an index as the Primary Key, but nothing else. Will there be any noticeable difference between inserting rows now (empty table), with say 100,000 rows, and say 1,000,000 rows? I figure UPDATEs will be slower, but I'd say that an INSERT could be pretty much just as fast, as there are no indexes except for the primary key. Or am I wrong there?

Best Answer

When you are mass INSERTs into an InnoDB table with just a Primary Key you are building up the gen_clust_index (a.k.a. Clustered Index).

Secondary Indexes are built in conjunction with the Clustered Index. Since you have no Secondary Indexes, this reload would be just fine.

I would high recommend doing two things when reloading:

When you use the bulk insert buffer, it helps load the data into a treelike structure that makes it easier to load into a non-empty table.