Raised This Month: $51 Target: $400
 12% 

SQLite vs MySQL comparison


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Johnny got his gun
Veteran Member
Join Date: Jan 2004
Location: Tokyo
Old 02-20-2005 , 13:41   SQLite vs MySQL comparison
Reply With Quote #1

I've been investigating the speed of mysql vs sqlite. It sure takes careful benchmarking to get proper results. Here's what I have so far:

Quote:
Starting benchmark using "mysql", database "bench" at "127.0.0.1".
Iterations: Insert = 50000, Select = 100, Replace = 100000
Many connections: no (using transactions)
Created table.
Inserted data. start = 1108923983, end = 1108923993, difference = 10 seconds
Selected data. start = 1108923993, end = 1108924000, difference = 7 seconds
Replaced data. start = 1108924000, end = 1108924022, difference = 22 seconds
Benchmark done! Total time: 39 seconds
Performed 4 connections.
Quote:
Starting benchmark using "sqlite", database "bench" at "local disk file ;-)".
Iterations: Insert = 50000, Select = 100, Replace = 100000
Many connections: no (using transactions)
Created table.
Inserted data. start = 1108923939, end = 1108923944, difference = 5 seconds
Selected data. start = 1108923944, end = 1108923950, difference = 6 seconds
Replaced data. start = 1108923950, end = 1108923960, difference = 10 seconds
Benchmark done! Total time: 21 seconds
Performed 4 connections.
The benchmark does the following:
1. Drops previous table in case it already exists and recreates the table.
2. Inserts X amount of records (50000 above). Logs time taken.
3. Selects (and retrieves using dbi_field on all columns) all of the inserted records X times (100). Logs time taken.
4. Replace all records plus an additional X records with new values (50000 + 50000 = 100000). Logs time taken.
5. Logs overall time taken.

At first I got some horrible results for sqlite when inserting/replacing data. This was due to the fact that I didn't do proper transactions which really is a must if you're doing many inserts/updates/replaces. Inserting 100 records into an sqlite database took 11-12 seconds (!!!). Mysql only takes 0 seconds (yes not even a second). With transactions on, sqlite is down to 0 seconds as well for 100 records. And as you can see when trying with more records, it's even faster, at least on my system.

These numbers should probably be taken with a grain of salt because in the end there are a lot of other factors affecting the outcome speed. If the mysql database is on another computer on another network, it will of course take longer time. But sqlite doesn't even have that feature, so what do you do. :-)
Also you have to be very delicate about how you query the database. Not using transactions really made sqlite stink insert-wise. Maybe it's a good practice to always use transactions when inserting data, to be honest this was nothing I knew much about until I researched the horrible insert times of sqlite.
Don't think anyone's interested, but if you are I'm uploading the benchmarking plugin. It should work for the other dbi modules as well, provided that the SQL syntax is right.

Making SQL code that will work well for both mysql and sqlite seems a little tricky. I wonder how Mysql can get that low insert times without using transactions when sqlite obviously can't.
Attached Files
File Type: sma Get Plugin or Get Source (sql_benchmarking.sma - 1189 views - 13.7 KB)
Johnny got his gun is offline
BAILOPAN
Join Date: Jan 2004
Old 02-20-2005 , 18:00  
Reply With Quote #2

They really have totally different uses. Sqllite doesn't support many things and mysql doesn't support many things that better software does (postgresql).
__________________
egg
BAILOPAN is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:22.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode