Re: We find few queries running three times simultaneously with sameparameters on postgres db - Mailing list pgsql-general

From amandeep singh
Subject Re: We find few queries running three times simultaneously with sameparameters on postgres db
Date
Msg-id MAXPR0101MB1915FEE2A4BC0B7B8DA71F1880480@MAXPR0101MB1915.INDPRD01.PROD.OUTLOOK.COM
Whole thread Raw
In response to Re: We find few queries running three times simultaneously with sameparameters on postgres db  (Edson Carlos Ericksson Richter <richter@simkorp.com.br>)
Responses Re: We find few queries running three times simultaneously with sameparameters on postgres db  (amandeep singh <singh_a@live.in>)
List pgsql-general
Thanks Edson for ur support.

As I am not a developer , I will share this test case with development team.

Once I get feedback from team, will share it on this mailing list.

From: Edson Carlos Ericksson Richter <richter@simkorp.com.br>
Sent: Wednesday, June 27, 2018 2:02:19 PM
To: pgsql-general@lists.postgresql.org
Subject: Re: We find few queries running three times simultaneously with same parameters on postgres db
 
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 by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: EXTERNAL: Re: Database name with semicolon
Next
From: amandeep singh
Date:
Subject: Re: We find few queries running three times simultaneously with sameparameters on postgres db