Solved

What is better: 1 composed index or 2 indexes on sqlite?

Posted on 2013-06-29
5
623 Views
Last Modified: 2013-06-30
Hi.

I'm creating a geolocalized app for Android and iPhone. This app shows a map with some interesting points that are on an sqlite database embeded on the app.

User can zoom out so then some too-many-markers technique is applyied, so a lot of points can be shown but grouped.

The interesting points are stored on a table which have a field for gps longitude and another field for gps latitude.

My question is: what is better for improve performance? To create 2 different index (one for gps_latitude, and one for gps_longitude) or to create 1 single icomposed index that includes two fields?

SELECT statements queries this table with a WHERE clause like this:

WHERE gps_longitude > ? AND gps_longitude < ?
     AND gps_latitude > ? AND gps_latitude < ?

Thank you.
0
Comment
Question by:gplana
  • 3
  • 2
5 Comments
 
LVL 50

Accepted Solution

by:
Steve Bink earned 500 total points
ID: 39287618
According to the optimization details of MySQL, it sounds like you'll be better off with two single-field indexes.  

In the end, the best way is to benchmark the performance of each approach using a healthy bit of sample data.  The actual performance will depend on the engine your application is using, and how it approaches index usage.
0
 
LVL 15

Author Closing Comment

by:gplana
ID: 39287738
Very useful. Thank you.
0
 
LVL 15

Author Comment

by:gplana
ID: 39287840
Sorry, just one single question here: the link you provided is about MySQL but my question was on sqlite. Is it the same?
0
 
LVL 50

Expert Comment

by:Steve Bink
ID: 39288150
They are not the same, which is why I suggested benchmarking the performance with the engine being used.  MySQL does not consider further index points once it hits a range evaluation for part of a multiple key index.  In my research on this question, I found other information that implies MSSQL (and other RDBMS) approach it differently.  I have no experience or technical background with sqlite.
0
 
LVL 15

Author Comment

by:gplana
ID: 39288157
ok, thanks.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article describes some very basic things about SQL Server filegroups.
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
This video is in connection to the article "The case of a missing mobile phone (https://www.experts-exchange.com/articles/28474/The-Case-of-a-Missing-Mobile-Phone.html)". It will help one to understand clearly the steps to track a lost android phone.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now