Search Postgresql Archives

Re: We find few queries running three times simultaneously with same parameters on postgres db

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





Get Outlook for Android



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@xxxxxxxxxxxxxxxxxxxx, 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

From: Edson Carlos Ericksson Richter <richter@xxxxxxxxxxxxxx>
Sent: Wednesday, June 27, 2018 2:02:19 PM
To: pgsql-general@xxxxxxxxxxxxxxxxxxxx
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




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux