I am using TokuDB from Percona Server 5.6.26-74.
I am sharing this because one day I might report perf results for some of the tests I do. I don't need a fix or an answer for this problem. But I don't want to surprise you with this result.
I was curious about the amount of extra space used to make the linktable secondary index covering for the most frequent query in linkbench. I ran the test for MyRocks and InnoDB without problems. Making the id1_type index non-covering saves space but reduces TPS for linkbench by about 20%.
My results with TokuDB were much worse. In one configuration I get more than 10,000 QPS with the covering secondary index and approximately 0 TPS with the non-covering secondary index. The DDL is below for the linktable. TPS drops to zero because the short range scan on linktable takes 20+ minutes when the secondary index is non-covering. This paste has an example query, explain output, PMP output and Linux perf output --
https://gist.github.com/mdcallag/4b3049933a345864b2943186a1c357a0The query plan looks OK. My PMP reading skills for TokuDB are not great. It looks like there is too much contention on frwlock but maybe that isn't the only problem. Even when I only have one client running one copy of the problem query, the problem query still takes many minutes, maybe 10 or 20, to finish.
For this test I used maxid1=1B and the test table is ~300G with TokuDB. The my.cnf for TokuDB was
https://gist.github.com/mdcallag/90b5ca45bfcbe48970757b84c9e0d983The standard DDL is:
CREATE TABLE `linktable` (
`id1` bigint(20) unsigned NOT NULL DEFAULT '0',
`id1_type` int(10) unsigned NOT NULL DEFAULT '0',
`id2` bigint(20) unsigned NOT NULL DEFAULT '0',
`id2_type` int(10) unsigned NOT NULL DEFAULT '0',
`link_type` bigint(20) unsigned NOT NULL DEFAULT '0',
`visibility` tinyint(3) NOT NULL DEFAULT '0',
`data` varchar(255) NOT NULL DEFAULT '',
`time` bigint(20) unsigned NOT NULL DEFAULT '0',
`version` int(11) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (link_type, `id1`,`id2`) COMMENT 'cf_link_pk',
KEY `id1_type` (`id1`,`link_type`,`visibility`,`time`,`id2`,`version`,`data`)
) ENGINE=TokuDB;
The non-covering version of id1_type is:
CREATE TABLE `linktable` (
`id1` bigint(20) unsigned NOT NULL DEFAULT '0',
`id1_type` int(10) unsigned NOT NULL DEFAULT '0',
`id2` bigint(20) unsigned NOT NULL DEFAULT '0',
`id2_type` int(10) unsigned NOT NULL DEFAULT '0',
`link_type` bigint(20) unsigned NOT NULL DEFAULT '0',
`visibility` tinyint(3) NOT NULL DEFAULT '0',
`data` varchar(255) NOT NULL DEFAULT '',
`time` bigint(20) unsigned NOT NULL DEFAULT '0',
`version` int(11) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (link_type, `id1`,`id2`) COMMENT 'cf_link_pk',
KEY `id1_type` (`id1`,`link_type`,`visibility`,`time`)
) ENGINE=TokuDB;
--