Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: SQLite and CPU Usage

by beable (Friar)
on Aug 02, 2004 at 10:33 UTC ( #379244=note: print w/replies, xml ) Need Help??

in reply to SQLite and CPU Usage

You need to identify the bottleneck. For example, is the I/O (disk) system running at 100% speed? If so, you won't be able to raise your CPU usage because you'll be waiting for I/O. (Unless you have some CPU-intensive task you can perform while waiting for I/O.) On the other hand, if I/O is not running at maximum capacity, and CPU is at 5%, then there must be something else slowing down your program.

Replies are listed 'Best First'.
Re^2: SQLite and CPU Usage
by PerlingTheUK (Hermit) on Aug 02, 2004 at 10:46 UTC
    Basically the hard drive is slowing me down, The problem is that SQLite does not support INSERT statements with a list of values (rows), so it seems to read after each statement. This is where I am looking for improvement at the moment but I have not really any idea how to start so.
    It seems SQLite reads the whole database files each time I execute an INSERT statement. Is there a way to reduce this? My tables have a primary key and therefore it should be eas to only check if this is existing.
    Would it be useful to include Indices for this? My table has no foreign keys and is only a list of names for an abbreviation which is the key.

      Turn off AutoCommit and manually commit your inserted rows ever 100 rows or so. The code is Class::DBI-ish but should be easily adapted to whatever your needs are:

      package ASE::DB; use strict; use base 'Class::DBI'; __PACKAGE__->set_db( Main => "dbi:SQLite:dbname=d:/data/ase.sqlite","" +,"", {RaiseError => 1, AutoCommit => 0} );

      Of course, then you have to commit at least at the end of your program run, or whenever a work unit has been processed:

        Thank you,
        I just added a BEGIN and COMMIT myself. Don't ask me Why I did not see these statements in the manual! Thank you for any help and sorry for asking such stupid questions.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://379244]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2023-04-02 07:49 GMT
Find Nodes?
    Voting Booth?

    No recent polls found