Epicurus
Epicurus

Reputation: 2133

INSERT DELAYED vs. Write-behind in PHP/MySQL

What is the best way to avoid the overhead generated by executing many INSERT queries for logging purposes in a PHP/MySQL application? So far I have narrowed the solutions down to:

  1. Using the INSERT DELAYED statement. I have a suspicion this will actually be slower, considering there will be many writes and few reads to queue and merge them behind.
  2. Using a cache module supporting write-behind. However, it seems like there is no such module for PHP. This is also discussed here, though the answers are 3 years old and new technology has emerged since then: How to implement background/asynchronous write-behind caching in PHP?

Not losing log entries is important.

Upvotes: 1

Views: 1504

Answers (1)

Johan
Johan

Reputation: 76641

Use the archive engine for the log tables.
It's optimized for the workload of keeping a log.

http://dev.mysql.com/doc/refman/5.0/en/archive-storage-engine.html

Note that this engine does not support indexes which speeds up inserts, but slows down selects.

Upvotes: 2

Related Questions