views:

1791

answers:

3

For reasons that are irrelevant to this question I'll need to run several SQLite databases instead of the more common MySQL for some of my projects, I would like to know how SQLite compares to MySQL in terms of speed and performance regarding disk I/O (the database will be hosted in a USB 2.0 pen drive).

I've read the Database Speed Comparison page at http://www.sqlite.org/speed.html and I must say I was surprised by the performance of SQLite but since those benchmarks are a bit old I was looking for a more updated benchmark (SQLite 3 vs MySQL 5), again my main concern is disk performance, not CPU/RAM.

Also since I don't have that much experience with SQLite I'm also curious if it has anything similar to the TRIGGER (on update, delete) events in the InnoDB MySQL engine. I also couldn't find any way to declare a field as being UNIQUE like MySQL has, only PRIMARY KEY - is there anything I'm missing?

As a final question I would like to know if a good (preferably free or open source) SQLite database manager exists.

+6  A: 

A few questions in there:

  1. In terms of disk I/O limits, I wouldn't imagine that the database engine makes a lot of difference. There might be a few small things, but I think it's mostly just whether the database can read/write data as fast as your application wants it to. Since you'd be using the same amount of data with either MySQL or SQLite, I'd think it won't change much.
  2. SQLite does support triggers: CREATE TRIGGER Syntax
  3. SQLite does support UNIQUE constraints: column constraint definition syntax.
  4. To manage my SQLite databases, I use the Firefox Add-on SQLite Manager. It's quite good, does everything I want it to.
Chad Birch
This is pretty thorough. For the manager, I would look at SQLiteman (sqliteman.com/). There are some annoying aspects (for instance, every time you modify a open SQL file, it pops up a new dialog box, even if one's already open). However, it is cross-platform and has the main functionality (execute arbitrary SQL, inspect and alter tables, create and execute views, etc.).
Matthew Flaschen
Thanks! =) Great answer!
Alix Axel
The difference is that MySQL will probably cache everything into RAM as much as possible. Sqlite can't - it is expecting the database to be unloaded all the time (and in fact is when you app restarts). MySQL can rely on being there a LOT longer and cache the data from disk for less I/O overall. Any server system would do this.
Jason Short
+2  A: 

In terms of disk I/O limits, I wouldn't imagine that the database engine makes a lot of difference.

In Mysql/myISAM the data is stored UNORDERED, so RANGE reads ON PRIMARY KEY will theoretically need to issue several HDD SEEK operations.

In Mysql/InnoDB the data is sorted by PRIMARY KEY, so RANGE reads ON PRIMARY KEY will be done using one DISK SEEK operation (in theory).

To sum that up: myISAM - data is written on HDD unordered. Slow PRI-KEY range reads if pri key is not AUTO INCREMENT unique field.

InnoDB - data ordered, bad for flash drives (as data needs to be re-ordered after insert = additional writes). Very fast for PRI KEY range reads, slow for writes.

InnoDB is not suitable for flash memory. As seeks are very fast (so you won't get too much benefit from reordering the data), and additional writes needed to maintain the order are damaging to flash memory.

myISAM / innoDB makes a huge difference for conventional and flash drives (i don't know what about SQLite), but i'd rather use mysql/myisam.

slawek
A: 

I actually prefer using SQLiteSpy http://www.portablefreeware.com/?id=1165 as my SQLite interface. It supports things like REGEXP which can come in handy.

What does that have to do with my question?
Alix Axel