Hi guys,

I would like to ask a question about sqlite in php. I don't know if I am
sending this message to the right place, but I don't know where else to ask.

Lately, I read in http://www.sqlite.org/speed.html, that sqlite is a bit
faster than mysql and postgreSQL. But, when I perform a little testing yo
compare them in php, I got a contrast result.

For both testing, I use this table :
CREATE TABLE test (a varchar(20) PRIMARY KEY, b varchar(20), c varchar(20),
                          d varchar(20), e varchar(20),  f varchar(20),
                          g varchar(20), h varchar(20),  i varchar(20), j
varchar(20))

for that table, I perform 5000 insert for both sqlite and mysql :
here's for sqlite code :
=============== sqlite-test.php ===============
$time_start = microtime(true);
$db = sqlite_open('pegawai.db', 0666, $sqliteerror);
for($i = 0; $i < 5000; $i++)
            {
                $sql = "INSERT INTO test VALUES
('a$i','b$i','c$i','d$i','e$i','b$i','b$i','b$i','b$i','b$i')";
                $q = sqlite_query($db, $sql);
            }
sqlite_close($db);
$time_end = microtime(true);
$time = $time_end - $time_start;
echo "executed in $time seconds\n";
=========================================

and here's for mysql code :
============= mysql-test.php ================
.............
$time_start = microtime(true);
for($i = 0; $i < 5000; $i++)
        {
            $sql = "INSERT INTO test VALUES
('a$i','b$i','c$i','d$i','e$i','b$i','b$i','b$i','b$i','b$i')";
            $q = mysql_query($sql);
        }
$time_end = microtime(true);
$time = $time_end - $time_start;
echo "executed in $time seconds\n";
..............
===========================================

when I run those 2 script, the first one (sqlite) run for 43.4918169975
seconds, while the second (mysql) only take 0.52137298584 seconds.

It means that sqlite run 80x longer than mysql did (very contrast with the
one I read in http://www.sqlite.org/speed.html).

Please tell me where do I did wrong. Thanks very much.

Regards,

------------------
Anton Rifco S

Student of Informatics Department
School of Electrical Engineering and Informatics
Institute Technology of Bandung
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to