I have the following EXPLAIN QUERY PLAN. It looks like it is using the correct index. But my query is still slow. I have around 20000 records in...

How It Works

Get an answer in three easy steps. Here's how it works...

Ask Your Question

1. Ask Your Question

Enter your SQLite question at the top of this page and click Get An Answer.

Pick Your Priority

2. Pick Your Priority

Tell us how quickly you want your SQLite question answered.

Get An Answer

3. Get An Answer

Connect with your programmer via online chat or telephone call.

Answer

Customer
I have the following EXPLAIN QUERY PLAN. It looks like it is using the correct index. But my query is still slow. I have around 20000 records in the database. Please help. sqlite> explain query plan select gName, sum(DIO) from group_process_status where Time between ***-***-**** 2218 and ***-***-**** 2218 group by gName order by gName; orde from deta ---- ------------- ---- 0 0 TABLE group_process_status WITH INDEX group_process_status_idx
Last updated
srl309
Programmer
you don't need the order by because it will be disabled anyway /* If there is both a GROUP BY and an ORDER BY clause and they are ** identical, then disable the ORDER BY clause since the GROUP BY ** will cause elements to come out in the correct order. This is ** an optimization - the correct answer should result regardless. ** Use the SQLITE_GroupByOrder flag with SQLITE_TESTCTRL_OPTIMIZER ** to disable this optimization for testing purposes. */ if( sqlite3ExprListCompare(p->pGroupBy, pOrderBy)==0 && (db->flags & SQLITE_GroupByOrder)==0 ){ pOrderBy = 0; } can you print out the explain data for the query
Posted
srl309
Programmer
Also if the between returns only a small amount of values you want the index on the between value. If it returns a large amount of values > 1/3 of the table you want it on the group by. That what i have found to be the case what is your index on
Posted

quoteTestimonialsquote

About ExpertHelp

ExpertHelp is changing the way you connect with service professionals.

Whether you have a quick question while preparing your taxes, troubleshooting a computer problem, or need to hire an attorney, ExpertHelp is the most convenient and affordable way to connect with the right service professional to get the job done.

ExpertHelp has been in business since 2011, is an A+ Rated Better Business Bureau accredited member, and offers a 100% satisfaction guarantee on every question you ask!

More SQLite Questions...

Ask Your SQLite Question & Get An Answer Now!