query-cache

Hibernate does not evict query cache (non repeatable read issue)

China☆狼群 提交于 2020-01-03 21:54:51
问题 I am a new to java/spring/hibernate and really felt in love in java after several years of .Net programming. now I am working on web app using Spring (MVC, declarative transactions) and Hibernate (3.6, as cache provier - ehCache 2.5). I've got some read only and read-write enitties that I would like to cache using Hibernate second cache and query cache. everything was alright when I used caching for read only entities. I added read-write entity and ran performance tests using jMeter. For read

Should I sacrifice my innodb_buufer_pool _size/RAM to make space for query_cache_size ?

丶灬走出姿态 提交于 2019-12-31 03:55:06
问题 I have a 16GB dedicated Mysql server database.My innodb_buffer_pool_size is set to around 11GB ,i am implementing query cache in my system ,which has a size of 80mb. From where should i make this space ,innodb_buffer_pool_size or RAM ? 回答1: Back in Jun 2014 I answered https://dba.stackexchange.com/questions/66774/why-query-cache-type-is-disabled-by-default-start-from-mysql-5-6/66796#66796 In that post, I discussed how InnoDB micromanages changes between the InnoDB Buffer Pool and the Query

Store Static Filter By Key Expression

那年仲夏 提交于 2019-12-22 16:30:54
问题 I've got an function which generates an expression to filter a table by it's primary key, when passed in an Object[] , this is very similar to Find function except that it doesn't materialize so you can pass an IQueryable around afterwards public static Expression<Func<T, bool>> FilterByPrimaryKeyPredicate<T>(this DbContext dbContext, object[] id) { var keyProperties = dbContext.GetPrimaryKeyProperties<T>(); var parameter = Expression.Parameter(typeof(T), "e"); var body = keyProperties // e =

MySQL cache and date functions

风格不统一 提交于 2019-12-12 10:40:51
问题 I once read in a performance blog that it is better to use PHP's date functions to set dates in a MySQL query instead of using mysql date functions like curdate() because mysql can then cache the query or the result or something like that. Does anyone have any insight into this? Does it hold any water or is it baseless? example: $query = 'SELECT id FROM table WHERE publish_date = \''.date('Y-m-d').'\''; vs $query = 'SELECT id FROM table WHERE publish_date = CURDATE()'; 回答1: Any function

How query cache works for scalar results?

五迷三道 提交于 2019-12-11 05:03:16
问题 I am new to Hibernate and I have the following piece of code in my DAO implementation class: public Integer getEmployeeCode(String userName) { Session session = sessionfactory.getCurrentSession(); Query q = session.createQuery("select emp.employeeCode from Employee emp where emp.userName = :username"); q.setString("username",userName); Integer p = (Integer) q.setCacheRegion("UserNameToCode").setCacheable(true).uniqueResult(); I am using Hibernate with EhCache. I am wondering if I am using

How to enable hibernate query cache on a session level only?

喜欢而已 提交于 2019-12-07 03:05:40
问题 What if I have a query that gets called multiple times in a single thread, and I just want to cache that query (and its result) for that thread (or for that session since I'm using one session per thread), how can I do that ? Note: My 2nd level cache is turned on but it's used mostly for session.get(...). But I do not want to use it for my query cache because I only need it to live for the duration of my thread ( / session ). Thanks 回答1: The bottom line here is: you can either manually cache

Very slow: ActiveRecord::QueryCache#call

自闭症网瘾萝莉.ら 提交于 2019-12-06 18:48:01
问题 I have an app on heroku, running on Puma: workers 2 threads_count 3 pool 5 It looks like some requests get stuck in the middleware, and it makes the app very slow (VERY!). I have seen other people threads about this problem but no solution so far. Please let me know if you have any hint. ! ! 回答1: I work for Heroku support and Middleware/Rack/ActiveRecord::QueryCache#call is a commonly reported as a problem by New Relic. Unfortunately, it's usually a red herring as each time the source of the

Prepared Statement and Statement/Query Caching

空扰寡人 提交于 2019-12-06 17:05:47
问题 I am trying to understanding if Statement caching is useful in case of parametrized prepared statements. As per my understanding If I use caching, then query will cached based on its 'String'. In this case, if a query has different values of parameter then it is a different / new statement/string w.r.t. caching. Also, when parameters change, the results also change. Since prepared statements are parameterized, is it really useful to use caching in this case. I am using JDBC/Snaq DB Pool/

Store Static Filter By Key Expression

自作多情 提交于 2019-12-06 10:12:18
I've got an function which generates an expression to filter a table by it's primary key, when passed in an Object[] , this is very similar to Find function except that it doesn't materialize so you can pass an IQueryable around afterwards public static Expression<Func<T, bool>> FilterByPrimaryKeyPredicate<T>(this DbContext dbContext, object[] id) { var keyProperties = dbContext.GetPrimaryKeyProperties<T>(); var parameter = Expression.Parameter(typeof(T), "e"); var body = keyProperties // e => e.{propertyName} == new {id = id[i]}.id .Select((p, i) => Expression.Equal( Expression.Property

Hibernate First level Cache vs Query Cache

自闭症网瘾萝莉.ら 提交于 2019-12-06 08:41:30
问题 Is first level cache different from query cache in hibernate? I have seen articles mentioning about first level and query cache, so i am confused. 回答1: First level cache is enabled by default and is per session basis. Query cache is not enabled by default, is shared across multiple sessions and should always be used in conjunction with the second-level cache. To enable query cache, the following properties should be used: hibernate.cache.use_second_level_cache=true hibernate.cache.use_query