Solved

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

Posted on 2013-06-29
5
642 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Read about achieving the basic levels of HRIS security in the workplace.
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
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.

786 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