Re: We find few queries running three times simultaneously with sameparameters on postgres db
От | Edson Carlos Ericksson Richter |
---|---|
Тема | Re: We find few queries running three times simultaneously with sameparameters on postgres db |
Дата | |
Msg-id | bb8d3da7-7544-e298-0701-46bb7e7aeb66@simkorp.com.br обсуждение исходный текст |
Ответ на | Re: We find few queries running three times simultaneously with sameparameters on postgres db (amandeep singh <singh_a@live.in>) |
Ответы |
Re: We find few queries running three times simultaneously with sameparameters on postgres db
|
Список | pgsql-general |
Em 26/06/2018 14:26, amandeep singh escreveu: > Hi Andreas > > The value for $1 is same in all queries. > > @Edson: number of such running queries are always 3. I see. It seems a programming logic error to me. I also use JPA (Hibernate and/or EclipseLink) and I don't have such problem. But I could replicate your scenario doing the following (with EclipseLink, didn't test with Hibernate): 1) In persistence.xml, disable all caches (this is very important for make reproducible) 2) Load three Person records that live on same city (objects Person and City mapped to tables Person and City, being city an attribute of Person object): TypedQuery<Person> qry = em.createQuery("select P from Person P where P.city.name = :cityname"); qry.setParameter("cityname", "Porto Alegre"); qry.setMaxResults(3); List<Person> rs = qry.getResultList(); 3) This will cause one query against Person table, and exactly 3 queries issued with same parameters to City table. I really don't know how your code works, and is quite hard to guess, but as you can see, it is easy to reproduce similar behavior. Now, if I enable EclipseLink caches, only one query is issued for each City key - so, I'll have one query for Person and one query for only. Hope this helps to enlighten your problem. :-) Regards, Edson
В списке pgsql-general по дате отправления: