Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: tiflash主键问题
Currently, when a string type is used as the primary key, an implicit rowid is generated as the actual primary key. I would like to understand the reasons and considerations for not using the string type as the actual primary key. By the way, in the current implementation, I understand that performing a group by on a string type will have significant performance overhead. If the string type is set as the primary key, would this issue no longer exist?
Using characters as primary keys has significant performance overhead. UTF8MB4 uses 4 bytes per character, so a 64-character key would be a 256-byte string for group by.
The performance is too poor.
In the case of using varchar as the primary key, will the implicit rowid and the set varchar primary key or composite primary key maintain a certain mapping relationship, or are they completely unrelated?
In the case of using varchar or multiple columns combined as a primary key, will the implicit rowid and the set varchar primary key or combined primary key maintain a certain mapping relationship, or are they completely unrelated?
There is a mapping relationship.
I suggest watching the video course on TiDB database table structure design.
https://learn.pingcap.com/learner/course/120005
I can’t watch this video, and the content is a bit much. Is there any related documentation available to read?
This video is available for a limited time and can be watched~
After reading the relevant documentation, it seems that the value of rowid has nothing to do with the primary key, but is only related to the auto_increment attribute. Is this correct?
If there is no relationship, how do you perform KV mapping?
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.