Skip to main content
The following query adds up the order totals after a date, as a monthly report would. It reads the example schema:
The query has no predicate on the shard key user_id, so the plan scatters to every shard in the group. Each shard computes a partial sum, and the router sums the partial sums. The following sections give the complete output of the query for EXPLAIN (NEKI_PLAN) and EXPLAIN (NEKI_PG_PLAN), in each of the four output formats. Query planning explains the EXPLAIN modes and their options.

EXPLAIN (NEKI_PLAN)

Replace TEXT with JSON, XML, or YAML for the other formats.
The route’s Query shows the date literal as $1. Neki replaces literal values with parameters before it looks up a plan, as Query plan cache and protocols describes.

EXPLAIN (NEKI_PG_PLAN)

The route also shows the Postgres plan from every shard in its shard group.

Need help?

Get help from the PlanetScale Support team, or join our Discord community to see how others are using PlanetScale.