Live data from Hacker News

How does database sharding work?

planetscale.com

111–113 of 113 posts

Re: How does database sharding work?

#111
post #22

Earlier quoted context omitted.

>Pick a a stable, guaranteed-to-exist, shard key (composite or atomic properties) and use that. This is a pretty risky approach since it's almost certainly the case that you won't end up evenly distributing your data across shards using this method.

more recent customers/users/accounts probably do more actions than very old accounts though, how is that not also eventually creating uneven shards?

While high volume multi-tenant "customers/users/accounts" systems are common, they are not the only ones which benefit from sharded persistent stores.

For example, consider a system which monitors farm equipment for Caterpillar and John Deere. Lets say each company has 100k devices which send one message per day to the system.

While it is easy to envision sharding device messages based on "DeviceId / Company" in this hypothetical system, there would be no value sharding the two customers.

Re: How does database sharding work?

#113

Does anyone else use planet scale but find it extremely slow? I'm using planetscale trial, simple queries can easily take 3-4s "cold", and then seem to get a little faster once presumably I hit cache.

Hey, I work for PlanetScale.

Definitely not normal. It’s hard to know why you’re seeing slow queries without more information.

The most common causes are either: missing indexes or network latency between the app and database (are they in the same region?).

We don’t have cold starts, but it is possible for queries to get faster once data is moved into memory. 3-4s is very slow though, I suspect it’s doing a full table scan and an index will solve it.

If you check Insights you can get more info, would also help to run an explain on the query (https://planetscale.com/courses/mysql-for-developers/queries...) to see what’s happening.

Also, if you email support, they’ll help debug it for you. Hope that helps!

Post reply on HN