pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: amandeep singh <singh_a@live.in>
To: pgsql-general@lists.postgresql.org <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 15:15:26 +0000
Message-ID: <MAXPR0101MB191589715ABB8EAAABC54CEC80480@MAXPR0101MB1915.INDPRD01.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <MAXPR0101MB1915FEE2A4BC0B7B8DA71F1880480@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>
	<bb8d3da7-7544-e298-0701-46bb7e7aeb66@simkorp.com.br>
	<MAXPR0101MB1915FEE2A4BC0B7B8DA71F1880480@MAXPR0101MB1915.INDPRD01.PROD.OUTLOOK.COM>



Get Outlook for Android<https://aka.ms/ghei36;



From: amandeep singh
Sent: Wednesday, 27 June, 8:42 PM
Subject: Re: We find few queries running three times simultaneously with same parameters on postgres db
To: pgsql-general@lists.postgresql.org, Edson Carlos Ericksson Richter


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.

Get Outlook for Android<https://aka.ms/ghei36;

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

view thread (10+ messages)

Message-ID: <MAXPR0101MB191589715ABB8EAAABC54CEC80480@MAXPR0101MB1915.INDPRD01.PROD.OUTLOOK.COM>
Permalink:  ../MAXPR0101MB191589715ABB8EAAABC54CEC80480@MAXPR0101MB1915.INDPRD01.PROD.OUTLOOK.COM/
Also on:    postgresql.org/message-id/MAXPR0101MB191589715ABB8EAAABC54CEC80480@MAXPR0101MB1915.INDPRD01.PROD.OUTLOOK.COM

 · 

reply

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: singh_a@live.in
  Subject: Re: We find few queries running three times simultaneously with same parameters on postgres db
  In-Reply-To: <MAXPR0101MB191589715ABB8EAAABC54CEC80480@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> <bb8d3da7-7544-e298-0701-46bb7e7aeb66@simkorp.com.br> <MAXPR0101MB1915FEE2A4BC0B7B8DA71F1880480@MAXPR0101MB1915.INDPRD01.PROD.OUTLOOK.COM> <MAXPR0101MB191589715ABB8EAAABC54CEC80480@MAXPR0101MB1915.INDPRD01.PROD.OUTLOOK.COM>

* 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