in

System.Data.SQLite

An open source ADO.NET provider for the SQLite database engine

Database Connection Tuning

Last post 03-05-2009 10:28 PM by cheetah. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 02-23-2009 5:19 AM

    Database Connection Tuning

    I need help tuning the database connection parameters.

    I have 2 modes.

    Bulk Writing - 1 connection to the database (enforced by lockout and isolation). A new database is created and tons of data is bulk loaded into the file. Maximum performance is most important. Database corruption is not a big deal because the import can just run again.


    Reading minimal write - Caching large amounts of data is important. Multiple clients can connect so data integrity is of moderate concern. It's not the end of the world if a database gets corrupted. 

    My question is are there any other turning parameters I can apply to get maximum performance? In general I prefer performance over data integrity unless it's going to cause major unreliablity. Dirty reads, and no crash recovery are fine for both modes.

    Here's the turning parameters I have for Read minimal writes:

    this.ExecuteNonQuery("PRAGMA cache_size = 32768");
    this.ExecuteNonQuery("PRAGMA count_changes = 0");
    this.ExecuteNonQuery("PRAGMA journal_mode = DELETE");
    this.ExecuteNonQuery("PRAGMA read_uncommitted = 1");
    this.ExecuteNonQuery("PRAGMA synchronous = NORMAL");
    this.ExecuteNonQuery("PRAGMA temp_store = MEMORY");


    Data Connection String
    Data Source={0};FailIfMissing=False;Legacy Format=False;Cache Size=16384;Page Size=32768; // Where {0} is the file name.

    Filed under: , ,
  • 03-05-2009 10:28 PM In reply to

    Re: Database Connection Tuning

    In performance tuning for my app, I found that increasing the page size, depending on the data being read and written, could actually have a negative impact on performance.  Originally, I'd taken the page size down to its smallest legal value to try and reduce file overhead (which is important for some of my uses), but when performance became an issue, I tried increasing it, and found that larger pages actually slowed things down for me.  I never tried a page size as large as you are using though, I only tried 512, 1024, 2048, and 4096.

    If you are fine with redoing a bulk load in the face of a failure, I found that PRAGMA synchronous = OFF produced a considerable performance boost, though the integrity risk was inappropriate for me.

Page 1 of 1 (2 items)
Powered by Community Server (Commercial Edition), by Telligent Systems