Discussion on the KV Module of TiDB Server

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: tidb server之kv模块的探讨

| username: lijin

In the image, both simple queries and transactions need to go through the KV module. Since data needs to be fetched from TiKV rather than getting cached data from the KV module, why can’t these two types of queries directly forward the request to the TiKV client like complex queries? This could save the call chain and improve query efficiency, right?

| username: 有猫万事足 | Original post link

It should be that this diagram is not clearly explained.

You can take a look at this source code reading series.
The functions of these two modules are:

kv: KV engine interface and some common methods. The underlying storage engine needs to implement the interfaces defined in this package.
distsql: Abstraction of the distributed computing interface. This package isolates the logic between the Executor and the TiKV Client.

You can browse through the code under these two packages, and you will get a very clear sense.

So your conclusion is completely correct. The kv module is indeed the lowest-level interface.

Additionally, the kv module is not without caching; cachedb is under this package.

https://github.com/search?q=repo%3Apingcap%2Ftidb%20cacheDB&type=code

Both point_get and batch_point_get may use cachedb.

| username: lijin | Original post link

Okay, I’ll come back to read the source code once I’ve mastered the Go language.

| username: 有猫万事足 | Original post link

If you have experience with other programming languages, I highly recommend this Go language tour:

https://tour.go-zh.org/welcome/1

Going through the language features is really fast. Personally, I feel it’s much quicker than learning from books or videos.

| username: tidb菜鸟一只 | Original post link

Saved it, will study it when I have time…

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.