Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I wrote up some quick code in perl that simply does:</p> <ol> <li>Create the database</li> <li>Insert a record that only contains a single integer</li> <li>Retrieve the most recent record and verify that it returns what it inserted</li> </ol> <p>And it does steps #2 and #3 6000 times. This is obviously a considerably lighter workload than having an entire object/relational bridge. For this trivial case with SQLite it still took 17 seconds to execute, so your desire to have it take "a couple of seconds" is not realistic on "traditional hardware."</p> <p>Using the monitor I verified that it was primarily disk activity that was slowing it down. Based on that if for some reason you really do need the database to behave that quickly I suggest one of two options:</p> <ol> <li>Do what people have suggested and find away around the requirement</li> <li>Try buying some solid state disks.</li> </ol> <p>I think #1 is a good way to start :)</p> <p>Code:</p> <pre><code>#!/usr/bin/perl use warnings; use strict; use DBI; my $dbh = DBI-&gt;connect('dbi:SQLite:dbname=/tmp/dbfile', '', ''); create_database($dbh); insert_data($dbh); sub insert_data { my ($dbh) = @_; my $insert_sql = "INSERT INTO test_table (test_data) values (?)"; my $retrieve_sql = "SELECT test_data FROM test_table WHERE test_data = ?"; my $insert_sth = $dbh-&gt;prepare($insert_sql); my $retrieve_sth = $dbh-&gt;prepare($retrieve_sql); my $i = 0; while (++$i &lt; 6000) { $insert_sth-&gt;execute(($i)); $retrieve_sth-&gt;execute(($i)); my $hash_ref = $retrieve_sth-&gt;fetchrow_hashref; die "bad data!" unless $hash_ref-&gt;{'test_data'} == $i; } } sub create_database { my ($dbh) = @_; my $status = $dbh-&gt;do("DROP TABLE test_table"); # return error status if CREATE resulted in error if (!defined $status) { print "DROP TABLE failed"; } my $create_statement = "CREATE TABLE test_table (id INTEGER PRIMARY KEY AUTOINCREMENT, \n"; $create_statement .= "test_data varchar(255)\n"; $create_statement .= ");"; $status = $dbh-&gt;do($create_statement); # return error status if CREATE resulted in error if (!defined $status) { die "CREATE failed"; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload