Query Causing High Memory Usage in TiKV

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

Original topic: 查询导致tikv内存一直占用很高

| username: Tfc_andrew

[TiDB Usage Environment] / Test /
[TiDB Version]
[Reproduction Path] For the test_2 table in the database, performing a select count(1) operation takes about 40 seconds, with less than 1 billion rows of data.

[Encountered Problem] As the SQL executes, the memory usage of TiKV keeps increasing, and after execution, the memory remains occupied and cannot be released.
[Resource Configuration]

Before executing the query statement

After executing the query

It remains in this state
This is the information viewed in the shell connection tool, and the memory usage before executing the statement is generally around 2.5GB.

| username: Tfc_andrew | Original post link

This is TiKV memory monitoring.

| username: Tfc_andrew | Original post link

The parameters of the cluster are all default.

| username: xfworld | Original post link

Check the SQL top through the dashboard to see how much memory each SQL consumes and how long it takes to execute.

Memory will be released after TiDB initiates GC. If there are no slow SQLs, it will be automatically released after a while, usually the default is 10 minutes.

| username: zhanggame1 | Original post link

Is there only one PD in this cluster? There should be at least three, right?

| username: linnana | Original post link

TiDB Cloud? It’s not a dedicated server, right?

| username: Tfc_andrew | Original post link

Yes, only one is enabled. It’s a test environment. Will it have a significant impact?

| username: Tfc_andrew | Original post link

The marked one is the query I made. What are the other queries for?

I have observed before and checked that the default parameter is 10 minutes, but it has not been released even after 10 minutes.

| username: 像风一样的男子 | Original post link

How many replicas are there for 3 KV nodes? Is the data distribution uneven?

| username: Tfc_andrew | Original post link

I’m not quite sure what you’re saying. I’m also just learning TiDB. Can you explain how to check? I’ll take a look.

| username: xfworld | Original post link

Hybrid deployment increases the difficulty of memory management. It is recommended that you reconfigure according to some suggestions in the official documentation:

If the configuration is high enough, it would be better to split it into multiple VMs to reduce resource competition… This will improve both the experience and troubleshooting.

| username: Tfc_andrew | Original post link

Okay, thank you. I’ll give it a try.

| username: system | Original post link

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