Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Handling a shard-key lookup across two databases

I wanted to build a lightweight database proxy that supports both MySQL and PostgreSQL. I was particularly interested in sharding and Redis-backed caching, because applications often end up implementing parts of that logic themselves. DBProxy is my way of exploring those problems. In this post, I’ll focus on one case: an IN query whose keys belong to two database shards. A batch lookup in an…

DBProxy is a lightweight database proxy that supports both MySQL and PostgreSQL, with a focus on sharding and Redis-backed caching. The article discusses handling a shard-key lookup across two databases when executing an IN query with tenant IDs belonging to two database shards. DBProxy partitions the request into separate queries for each shard and allows the application to combine the results.

In case of a shard failure, DBProxy buffers the results and checks metadata before returning rows, while also setting row, byte, and deadline limits to manage the cost of buffering. Additionally, DBProxy offers an optional Redis or Valkey read-through cache for MySQL, which is enabled per table and applies to eligible buffered, replica-eligible SELECT queries.

Brief written by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

More from Saturday, 28 November 2026 →