Solved

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

Posted on 2013-06-29
5
667 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 51

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 51

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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

622 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