in

System.Data.SQLite

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

Help: Database optimization

Last post 05-24-2010 10:49 AM by alexspence. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 05-13-2010 7:18 AM

    Help: Database optimization

    I'm new to SQLite, but have been working with SQL Server and mySQL for several years so I'm not entirely blind on this.

    Trying to figure out how to cut down on the execution time of a query.  Situation is I have a relatively simple table, with three fields:  id (integer, primary key), hash (text), category (integer).

    Problem is I have to put 6.5+ million records into it.  I've created an Index on the category field, and there is a (mostly useless) index as part of the id field's primary key status.  Running the following query, though, takes 3.5 minutes:

     

    SELECT category, COUNT(category) AS total

    FROM table_name

    GROUP BY category

    ORDER BY category

     

    I'm using the System.Data.SQLite dll to work within a Visual Basic .NET Windows application.  I've fiddled with increasing or decreasing the PRAGMA cache_size and setting temp_store to run in MEMORY, I've dropped and recreated the index after loading in the data (which also took forever), I've tried the VACUUM.

    Is there something I'm missing?  I haven't seen anything in my online searching to indicate that 6.5 million records is a problem - the limits I've seen are up in "pedibytes"...

  • 05-24-2010 10:49 AM In reply to

    Re: Help: Database optimization

    I would suggest using a seperate table to store your unique categorys and counts since you have so many records in that table.  Create some triggers to keep it up to date..
Page 1 of 1 (2 items)
Powered by Community Server (Commercial Edition), by Telligent Systems