The execution plan cache is not effective when performing JDBC batch inserts

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

Original topic: jdbc batch insert的时候执行计划缓存不生效

| username: dxss-lee

Using JDBC’s prepare statement and batchexecute method to insert data with a batch size of 4000, I cannot see queries using plan cache ops on the performance overview panel, and the proportion of dbtime spent on compilation is relatively high.

| username: h5n1 | Original post link

In TiDB monitoring, you can view the request command types through Query Summary > QPS By Instance. If COM_QUERY in the request is replaced by COM_STMT_EXECUTE or COM_STMT_PREPARE, it takes effect.

| username: dxss-lee | Original post link

I couldn’t find QPS by instance, only CPS by instance. [IMG_2890.HEIC|attachment]

| username: h5n1 | Original post link

It should be a mistake on the official website.

| username: dxss-lee | Original post link

I couldn’t find any of the metrics you mentioned.

| username: dxss-lee | Original post link

But it seems to be reused in the dashboard, seeking explanation.

| username: zzzzzz | Original post link

Try using JDBC:mysql://{TiDBIP}:{TiDBPort}/{DBName}?characterEncoding=utf8&useSSL=false&useServerPrepStmts=true&cachePrepStmts=true&prepStmtCacheSqlLimit=10000000&useConfigs=maxPerformance&rewriteBatchedStatements=true&defaultfetchsize=-2147483648

(JDBC Driver 5.1 has better compatibility)

| username: system | Original post link

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