From: Edson Carlos Ericksson Richter <richter@simkorp.com.br>
To: pgsql-general@lists.postgresql.org
Subject: Re: We find few queries running three times simultaneously with same parameters on postgres db
Date: Wed, 27 Jun 2018 11:02:19 -0300
Message-ID: <bb8d3da7-7544-e298-0701-46bb7e7aeb66@simkorp.com.br> (raw)
In-Reply-To: <MAXPR0101MB1915D511FAD2B161D13EDD0380490@MAXPR0101MB1915.INDPRD01.PROD.OUTLOOK.COM>
References: <MAXPR0101MB191541848D3CD85B118AC07080490@MAXPR0101MB1915.INDPRD01.PROD.OUTLOOK.COM>
<d27c8cfc-043a-01f5-5727-d19c96291a55@a-kretschmer.de>
<F1A212EE-F14B-476E-9875-713B6971E25F@a-kretschmer.de>
<MAXPR0101MB1915D511FAD2B161D13EDD0380490@MAXPR0101MB1915.INDPRD01.PROD.OUTLOOK.COM>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: richter@simkorp.com.br
Subject: Re: We find few queries running three times simultaneously with same parameters on postgres db
In-Reply-To: <bb8d3da7-7544-e298-0701-46bb7e7aeb66@simkorp.com.br>
References: <MAXPR0101MB191541848D3CD85B118AC07080490@MAXPR0101MB1915.INDPRD01.PROD.OUTLOOK.COM> <d27c8cfc-043a-01f5-5727-d19c96291a55@a-kretschmer.de> <F1A212EE-F14B-476E-9875-713B6971E25F@a-kretschmer.de> <MAXPR0101MB1915D511FAD2B161D13EDD0380490@MAXPR0101MB1915.INDPRD01.PROD.OUTLOOK.COM> <bb8d3da7-7544-e298-0701-46bb7e7aeb66@simkorp.com.br>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox