[MDEV-14516] TokuDB duplicates PK columns in secondary index Created: 2017-11-27  Updated: 2018-01-29  Resolved: 2018-01-29

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - TokuDB
Affects Version/s: 10.1.29
Fix Version/s: N/A

Type: Bug Priority: Minor
Reporter: Julien Muchembled Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: upstream


 Description   

Given the following table:

CREATE TABLE IF NOT EXISTS obj (
  `partition` SMALLINT UNSIGNED NOT NULL,
  oid BIGINT UNSIGNED NOT NULL,
  tid BIGINT UNSIGNED NOT NULL,
  data_id BIGINT UNSIGNED NULL,
  value_tid BIGINT UNSIGNED NULL,
  PRIMARY KEY (`partition`, oid, tid),
  KEY tid (`partition`, tid, oid),
  KEY (data_id)
) ENGINE=TokuDB;

tokuftdump shows that the 'tid' index duplicates all columns of the primary key whereas they're already in the secondary key. IOW, TokuDB stores:

<partition><tid><oid><partition><oid><tid> => ''

instead of only (like InnoDB):

<partition><tid><oid> => ''

This is quite space inefficient with all the obvious consequences (less efficient caches, more time to compress).



 Comments   
Comment by Sergei Golubchik [ 2017-11-28 ]

Yes, that's how TokuDB (and InnoDB too) works. The primary key is the row identifier, all secondary keys refer to a row by storing the corresponding primary key.

There are many articles and blog posts about using short primary keys for InnoDB, you can find some suggestions there.

Comment by Sergei Golubchik [ 2017-11-28 ]

Also, in your example, apparently, TokuDB does not remove redundant columns from the index definition.

If you'd want to have this fixed, try to report a bug to Percona, who own and maintain TokuDB nowadays.

Comment by Julien Muchembled [ 2017-11-28 ]

> Also, in your example, apparently, TokuDB does not remove redundant columns from the index definition.

That's the point of this MDEV. Maybe the title is misleading.

Not sure it should remain closed.

> If you'd want to have this fixed, try to report a bug to Percona, who own and maintain TokuDB nowadays.

Ok, I will. As a user of MariaDB, I reported it first in case there's any difference with Percona. And I also saw existing bug reports for TokuDB here.

Comment by Sergei Golubchik [ 2017-11-28 ]

okay, I'll reopen it and mark as "upstream". After Percona fixes it, we could be able to merge the fix.

Comment by Julien Muchembled [ 2018-01-29 ]

TDB-86 was closed as Won't Fix (for Percona, it's too much work for the improvement). You may want to do the same.

Comment by Elena Stepanova [ 2018-01-29 ]

Closed based on the comment above.

Generated at Thu Feb 08 08:14:11 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.