In this post we’ll describe a query that accrued significant
performance advantages from using a relatively long index
key. (This posting is by Zardosht and Bradley.)
We ran across this query recently when interacting with a
customer (who gave us permission to post this sanitized version
of the story):
SELECT name,
Count(e2) AS CountOfe2
FROM (SELECT distinct name, e2
FROM (SELECT atable.NAME AS name,
pd1.NAME AS e2
FROM atable INNER JOIN atable AS pd1
ON (atable.id = pd1.id)
AND (atable.off = pd1.off)
AND (atable.len = pd1.len)) ent
WHERE ((ent.name<>ent.e2))) outside
GROUP BY outside.name order by CountOfe2 desc;
With a table defined as
CREATE TABLE `atable` ( `id` varchar(25) DEFAULT NULL, `off` bigint(20) DEFAULT NULL, `len` bigint(20) DEFAULT NULL, `name` …[Read more]