Sharding
Route queries to the right shard by user, schema, or table — with no application changes.
Architectural Value
ProxySQL's advanced query rule engine enables transparent sharding at the proxy layer. By intercepting and inspecting every query, ProxySQL can distribute data across shards based on user identity, schema, or table — through built-in rules or fully customized plugins.
Key Capabilities
- → User-Based Sharding: Direct traffic to isolated database segments per tenant or user group.
- → Schema & Table Routing: Map specific schemas or tables to dedicated backend nodes automatically.
- → Plugin Extensibility: Implement regex routing logic and port-based routing.
Architectural Review
Not sure if this fits your current stack? Our experts can help.
Schedule a Call →Sharding: Architectural Deep-Dive
The Problem
At scale, a single database node becomes a ceiling. Whether the constraint is write throughput, storage capacity, or the operational risk of a single point of failure holding all your data, horizontal partitioning eventually becomes necessary. The standard answer is sharding — distributing data across multiple independent database instances, each owning a subset of the total dataset.
The hard part isn’t the databases themselves. It’s the routing layer. Every query that arrives from an application needs to be directed to the correct shard. Implement that logic in the application and you’ve coupled every service, every ORM, and every query path to your sharding scheme. Changing shard boundaries, rebalancing data, or adding new shards becomes a coordinated engineering effort that touches application code across your entire stack.
The ProxySQL Approach
ProxySQL intercepts every query before it reaches any backend and evaluates it against a routing rule set that you define and own entirely at the infrastructure layer. The application connects to a single ProxySQL endpoint, issues queries as normal, and is never aware that the data lives across multiple physical nodes. The sharding logic lives in the proxy, not in the application.
Rules can match on any dimension that is present in or around the query — and routing decisions are made in microseconds before any backend connection is acquired.
What You Can Do With It
User-Based Sharding is the natural model for multi-tenant architectures. Each tenant or user group connects with credentials that ProxySQL maps directly to an isolated backend host group. Tenant A’s queries never touch Tenant B’s database node. Isolation, compliance boundaries, and per-tenant scaling all become enforceable at the infrastructure layer without the application implementing any tenancy-aware routing logic.
Schema and Table Routing allows ProxySQL to inspect the target schema or table referenced in a query and direct it to the appropriate backend automatically. Specific schemas can be pinned to dedicated nodes, and table-level routing rules can distribute workload across backends based on access patterns. A reporting schema hitting a dedicated analytics node, a hot table isolated to its own instance — these become routing rules rather than application architecture decisions.
Plugin Extensibility handles the cases where declarative rules aren’t sufficient. ProxySQL’s plugin system allows custom sharding logic to be implemented and loaded without modifying ProxySQL’s core. Key-range sharding, hash-based distribution, lookup-table routing — any sharding scheme your data model requires can be expressed as a plugin and applied transparently to all traffic passing through the proxy.
The Result
Sharding through ProxySQL makes horizontal partitioning an infrastructure concern rather than an application concern. Your services connect to one endpoint, issue standard SQL, and remain completely decoupled from the physical layout of your data. Shard boundaries can be redrawn, backends can be added, and routing rules can be updated without touching application code or coordinating deployments across teams. The complexity of operating a sharded database lives where it belongs — in the layer purpose-built to manage it.