Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8206245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:36:05+00:00 2026-06-07T08:36:05+00:00

I need to fetch some data based on a keyword, the query is tested

  • 0

I need to fetch some data based on a keyword, the query is tested to 100% accurate, but the problem is the the loading of the reader is pretty slow. I have tried replacing this query with one that does not contain inner joins at all and the loading was pretty fast. So I wonder, since I am only selecting one column as a result, why does DataTable.Load() take so much time? Is it the SQLite‘s ExecuteReader that loads the whole results and not just the one column?

Before using the DataTable, the average time of executing each reader.Read() was 7 seconds.

This is my code:

_database.Connect();

var selectCommand = new SQLiteCommand(
@"SELECT A.ID AS MY_ID FROM MD 
INNER JOIN TMD ON MD.ID = TMD.ID_MD 
INNER JOIN TR ON TR.ID = TMD.ID_TR 
INNER JOIN P ON P.ID = TR.ID_P 
INNER JOIN DP ON DP.ID_P = P.ID 
INNER JOIN CD ON CD.ID = DP.ID_CD 
WHERE CD.DESC = @desc"
);

selectCommand.Parameters.AddWithValue("@desc", value);

using (DbDataReader reader = _database.ExecuteQuery(selectCommand))
{
    DataTable data = new DataTable("MyData");
    data.Load(reader);
}
_database.Disconnect();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T08:36:06+00:00Added an answer on June 7, 2026 at 8:36 am

    The SQLite Query Planner offers some hints about query optimization for SQLite.

    Some items that may apply to your question:

    1.) Due to the implementation in SQLite you might try to re-order the multiple joins:

    The current implementation of SQLite uses only loop joins. That is to
    say, joins are implemented as nested loops. The default order of the
    nested loops in a join is for the left-most table in the FROM clause to
    form the outer loop and the right-most table to form the inner loop.

    So, depending on how the JOINs are constructed there might be a difference in performance.

    SQLite tries to optimize this automatically, but as far as I understood the documentation there is no guarantee for success (highlights by me):

    However, SQLite will nest the loops in a different order if doing so
    will help it to select better indices.
    […]
    Join reordering is automatic and usually works well enough that programmers
    do not have to think about it, especially if ANALYZE has been used to gather
    statistics about the available indices. But occasionally some hints from the
    programmer are needed.

    2.) Also, please note that INNER JOINS are internally converted into WHERE clauses, so any of the performance tips in the WHERE section of the document might apply, too:

    The ON and USING clauses of an inner join are converted into
    additional terms of the WHERE clause prior to WHERE clause analysis
    described above in paragraph 1.0. Thus with SQLite, there is no
    computational advantage to use the newer SQL92 join syntax over the
    older SQL89 comma-join syntax. They both end up accomplishing exactly
    the same thing on inner joins.

    3.) You might consider to select more columns in your statement, if there are any indexes on them:

    It is not necessary for every column of an index to appear in a WHERE
    clause term in order for that index to be used. But there can not be
    gaps in the columns of the index that are used.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to fetch images and some other data from server and then display
I have the following Query and i need the query to fetch data from
I need to run some code that will fetch some configuration values from the
Im using vb.net and I need to fetch data from two different tables and
I have Core Data setup in my app and need to fetch a bunch
I need to update some static site data periodically, so i am thinking of
I have a web based system where users should be able to fetch data
Basically, I need some parts of database data synchronized on up to several dozens
I need to access some data from an MS Access database and retrieve some
I wrote a RSS based application that will fetch some XML files, parse them

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.