you would need to give more info about your db, the data, etc. On my
Macbook Pro, I get 1000+ inserts a second for a random 100 byte string
insert (that is, less than one per ms). That includes the time to
generate the string, and is all in Perl, while I am listening to
iTunes, and no funny pragma trix. Code follows...

I am using SQLite 3.4.2

CREATE TABLE foo (a);

sub speedtest {
  $sth->execute( str() )
}

sub str {
  my $str;
  for (0 .. 99) {
    $str .= ('a' .. 'z')[int(rand(25)) + 1];
  }
  return $str;
}

timethis(1000, \&speed);

$ ./db.pl
timethis 1000:  2 wallclock secs ( 0.20 usr +  0.75 sys =  0.95 CPU) @
1052.63/s (n=1000)

On 12/3/07, Mark Riehl <[EMAIL PROTECTED]> wrote:
> I've got an application that logs real-time data.  Some of the data is
> periodic (every few secs), other data comes more frequently.
> Basically, I'm not dealing with bulk inserts, so, I can't queue things
> up and insert all at once.
>
> I'm noticing that my insert times are pretty slow (~5-50 ms on a Intel
> Core 2) for a single record of ~100 bytes.
>
> Any suggestions for speeding up single row inserts?  I saw some of the
> other threads on using transactions, but, not sure if that applied to
> single inserts.
>
> Here is a simple app I wrote to test the timing:
>
>    int rc = sqlite3_open("mydb.db", &db);
>
>     for (i = 0; i < 10; i++) {
>
>       printf("Executing %s\n", insertStatement);
>
>       gettimeofday(&before, 0);
>       rc = sqlite3_exec(db, insertStatement, NULL, NULL, &zErr);
>       gettimeofday(&after, 0);
>       if (rc != SQLITE_OK) {
>          ...
>         }
>       }
>
>       printf("Before %d %d\n", before.tv_sec, before.tv_usec);
>       printf("After %d %d\n", after.tv_sec, after.tv_usec);
>
>       sleep(1);
>     }
>
>     sqlite3_close(db);
>
> Thanks for the help,
> Mark
>
> -----------------------------------------------------------------------------
> To unsubscribe, send email to [EMAIL PROTECTED]
> -----------------------------------------------------------------------------
>
>


-- 
Puneet Kishor
http://punkish.eidesis.org/
Nelson Institute for Environmental Studies
http://www.nelson.wisc.edu/
Open Source Geospatial Foundation (OSGeo)
http://www.osgeo.org/
Summer 2007 S&T Policy Fellow, The National Academies
http://www.nas.edu/

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to