0

I have a sqlite database consist of 50 columns and more than 1.2 million rows. I'm using System.Data.Sqlite to work with Visual Studio 2013 C# language.

I used a very simple code to retrieve my data from database but it is taking too much time.

private SQLiteConnection sqlite;

public MySqlite(string path)
{
    sqlite = new SQLiteConnection("Data Source="+path+"\\DBName.sqlite");
}

public DataTable selectQuery(string query)
{
    SQLiteDataAdapter ad;
    DataTable dt = new DataTable();
    try
    {
        SQLiteCommand cmd;
        sqlite.Open();  
        cmd = sqlite.CreateCommand();
        cmd.CommandText = query;  //set the passed query
        ad = new SQLiteDataAdapter(cmd);
        ad.Fill(dt); //fill the datasource
    }
    catch (SQLiteException ex)
    {
        //exception code here.
    }
    sqlite.Close();
    return dt;
}

And, the select statement is:

select * from table

As I told you, it is a very simple code.

I want to know how to boost select operation performance to get the appropriate result. for this code the process takes up to 1 minute which I want to get to less than 1 second.

and another thing is that there seems to be some tags for configuring sqlite database but I don't know where to apply them. could some one tell me how to configure sqlite database with System.Data.Sqlite;

Masoud Mohammadi
  • 1,721
  • 1
  • 23
  • 41
H.A
  • 66
  • 1
  • 11

1 Answers1

0

Consider narrowing your result set by getting necessary columns or paging.

G.Anıl Yalçın
  • 188
  • 1
  • 14