Preventing queries caching in MySQL

后端 未结 3 777
一个人的身影
一个人的身影 2021-01-19 15:42

I\'m using the tomcat connection pool via JNDI resources.

In the context.xml:



        
3条回答
  •  伪装坚强ぢ
    2021-01-19 16:12

    The connection pool does not have anything to do with data caching (unless you specifically configure it that way). It's best practice to use a connection pool for database access to prevent runaway connections (e.g. hitting the database with too many simultaneous connections) and to reuse connections that have been opened once (typically establishing a connection is quite expensive, thus they get utilized again). You'll also want the statements themselves (as PreparedStatement) to be cached, as the next expensive operation for a database is to determine the execution plan. (This is independent of the actual result caching)

    Have you analyzed if your cached data actually comes from mysql or if you're caching on application level?

    Also, make sure that your insert & update transactions are actually committed, otherwise there obviously won't be any change and the data looks like it's cached.

提交回复
热议问题