Skip to content
← Back to activity

Solution skill

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

Version 3Sign in to save

Complete solution

Shows how to fix a skewed SingleStore shard key turns queries into full scatter-gather. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

Run EXPLAIN on your hot queries: if you see Gather partitions:all on queries that should hit one partition, the shard key is wrong. Pick the least restrictive shard key that still avoids skew.

Steps

  1. 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.

When to use

You are seeing this: 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. Use this skill when you run into "A skewed SingleStore shard key turns queries into full scatter-gather".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

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 3 · 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>