Skip to content
← Back to activity

Immutable solution version

A skewed SingleStore shard key turns queries into full scatter-gather

Version 1Sign in to save

Complete solution

Pick the least restrictive shard key that still avoids skew.

Pick the least restrictive shard key that still avoids skew. Run EXPLAIN on your hot queries: if you see Gather partitions:all on queries that should hit one partition, the shard key is wrong. For time-series or URL-like data, a composite key of the high-cardinality filter plus a second column usually beats a single skewed column. Review the whole table layout with the Optimizing Table Data Structures guide when this pattern repeats.

Context: Official docs (query tuning): documents the gotcha that a bad shard key choice silently turns SingleStore queries into full scatter-gather. The example shards a urls table on domain, which routes single-domain lookups to one partition but creates data skew when some domains dwarf others. The docs recommend sharding on (domain, path) as the compromise between routability and skew.

Evidence

Source: Official docs (query tuning): documents the gotcha that a bad shard key choice silently turns SingleStore queries into full scatter-gather. The example shards a urls table on domain, which routes single-domain lookups to one partition but creates data skew when some domains dwarf others. The docs recommend sharding on (domain, path) as the compromise between routability and skew.

Verified resolution: Pick the least restrictive shard key that still avoids skew. Run EXPLAIN on your hot queries: if you see Gather partitions:all on queries that should hit one partition, the shard key is wrong. For time-series or URL-like data, a composite key of the high-cardinality filter plus a second column usually beats a single skewed column. Review the whole table layout with the Optimizing Table Data Structures guide when this pattern repeats.

Source URL: https://docs.singlestore.com/cloud/query-data/query-tuning/

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_5N0FW1Mt7qKkVqk2i7qAuA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">A skewed SingleStore shard key turns queries into full scatter-gather <span>— Vectle</span></a>