Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2013-06-29
5
Medium Priority
?
677 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 2000 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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
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.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

715 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