[SERVER-5237] We're planning on changing our shard key. We'd like your opinion on whether it makes sense or not. Created: 07/Mar/12  Updated: 11/Jul/16  Resolved: 17/Mar/12

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: 2.0.3
Fix Version/s: None

Type: Question Priority: Critical - P2
Reporter: Tim Shinnick Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux


Participants:

 Description   

We have a GIS based database. All documents contain longitude and latitude. Currently we have our shard key set to longitude. We are considering changing it to a combination of longitude and latitude. We believe that, in doing so, we will not only greatly increase the cardinality of keys, but will also distribute our data more evenly across the shards. We also expect to see an improvement in the time it takes to load and query data. We'd like your opinion on this.
Thanks in advance for you help.



 Comments   
Comment by Eliot Horowitz (Inactive) [ 17/Mar/12 ]

let us know if you need any more help

Comment by Tim Shinnick [ 08/Mar/12 ]

No. Like I said, I'm new to this. Jeff Cramer asked me if I had opened a CS request, so I thought I was doing that. But I see now that it's an "issue".

Comment by Eliot Horowitz (Inactive) [ 08/Mar/12 ]

lat,lng,timestamp would be fine.

Are you in CS? If so we can move this there but didn't see that you were.

Comment by Tim Shinnick [ 08/Mar/12 ]

I just got the answer to your precision question. We keep 14 decimal points. I also learned that adding "type" to our shard key wouldn't help, because there are too few values. So we're considering adding epoch timestamp to lat/long. That would make the key unique, right? Is epoch timestamp a value people commonly use as part of their shard key?

Eliot, as an aside, this is my first experience with Mongo and this online support. Let me know if I'm overstepping any boundaries. I know you already answered my initial question. Since then, I've added a couple of new ones. If I should be opening up a new CS request, let me know.

Thanks again

Comment by Eliot Horowitz (Inactive) [ 07/Mar/12 ]

What granularity is lat/long?
As long as there aren't going to be a lot of docs at the same location, it should be plenty.
What is the precision of lat/long you are using?
Could there be 64mb of data at the same lat/long? If so, then use all 3.

Comment by Tim Shinnick [ 07/Mar/12 ]

I really thought you were going to suggest lat/long/type. Is the reason that lat/long provide enough cardinality?

Comment by Eliot Horowitz (Inactive) [ 07/Mar/12 ]

Ok - so sharding on lat/long makes sense then.

Comment by Tim Shinnick [ 07/Mar/12 ]

I just heard from the app team. Most of the querying is done on latitude, longitude and type.

Comment by Tim Shinnick [ 07/Mar/12 ]

Thanks for the quick response. I'm waiting to hear back from the app team.

Comment by Eliot Horowitz (Inactive) [ 07/Mar/12 ]

At first glance that seems to make sense.
Longitude is probably not enough cardinality.

What is the most common way you query or modify the data?

Might be a better way.

Generated at Thu Feb 08 03:08:18 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.