9 Query and DML Execution
On a sharded database, queries and DML can be routed to the shards for execution with or without a sharding key. If a key is provided by the application a database request is routed directly to the shards, but if no key is provided the request is processed by the shard catalog, and then directed to the necessary shards for execution.
- How Database Requests are Routed to the Shards
In Oracle Sharding, database query and DML requests are routed to the shards in two main ways, depending on whether a sharding key is supplied with the request. - Connecting to the Query Coordinator
The Oracle Sharding query coordinator, a component of the shard catalog, contains the metadata of the sharded topology and provides query processing support for sharded databases. - Query Coordinator Operation
The SQL compiler in the shard catalog identifies the relevant shards automatically, and coordinates the query execution across all of the participating shards. Database links are used for the communication between the coordinator and the shards. - Query Processing for Single-Shard Queries
A single-shard query is a query which needs to scan data from only one shard and does not need to lookup data from any other shards. - Query Processing for Multi-Shard Queries
A multi-shard query is a query that must scan data from more than one shard, and the processing on each shard is independent of any other shard. - Supported Query Constructs and Example Query Shapes
Oracle Sharding supports single-shard and multi-shard query shapes with some restrictions. - Supported DMLs and Examples
DMLs in Oracle sharding can target either duplicated tables or sharded tables. There are no limitations on DMLs when the target is a duplicated table. - Gathering Optimizer Statistics on Sharded Tables
You can gather statistics on sharded tables from the coordinator database.