Assuming the same data volume and excluding hardware resource limits, cross-database queries across different RDS instances are theoretically faster than cross-database queries within a single RDS instance. This advantage is most pronounced in aggregate query scenarios.
Why cross-instance queries are faster
When queries span multiple RDS instances, each instance processes its own shard in parallel. This parallelism enables better utilization of CPU and I/O resources of ApsaraDB for RDS across two dimensions:
CPU load: Computation is distributed across multiple instances instead of concentrated on one.
I/O throughput: Read operations are parallelized across instances rather than concentrated on a single instance.
Under ideal conditions — same-spec instances — RT scales with the number of instances: RT (cross-instance) ≈ RT (single-instance) / N, where N is the number of RDS instances.
By contrast, when all shards reside in a single RDS instance, every query competes for that machine's CPU and I/O. As workload grows, this single instance becomes the resource bottleneck.
When to choose cross-instance distribution
Cross-instance distribution gives the most benefit for aggregate-heavy workloads — GROUP BY, COUNT, SUM, and similar operations — where each instance computes partial results in parallel and transmits only the compact aggregated output.