← Back to team overview

dhis2-users team mailing list archive

Re: [Dhis2-devs] Missing orderby clause in TrackedEntityInstance Ids query

 

Hi

Postgres should return the results in row-order if no order by clause is
specified, so it should be OK. You can always specify additional ordering
if you need it.

-- 
Morten Olav Hansen
Senior Engineer, DHIS 2
University of Oslo
http://www.dhis2.org

On Thu, Jun 7, 2018 at 8:54 AM, Rajeswari Gottipati <
rajeswag@xxxxxxxxxxxxxxxx> wrote:

> Hi DHIS team,
>
> We are hitting the below API to fetch TrackedEntityInstance(TEI) Ids
>
> http://<domain>/api/25/trackedEntityInstances?eventEndDate=2018-06-03&
> eventStartDate=2018-03-18&fields=trackedEntityInstance&
> ou=a2620f76786&ouMode=DESCENDANTS&page=1&pageSize=1000&totalPages=true
> <http://localhost:8080/api/25/trackedEntityInstances?eventEndDate=2018-06-03&eventStartDate=2018-03-18&fields=trackedEntityInstance&ou=a2620f71996&ouMode=DESCENDANTS&page=1&pageSize=1000&totalPages=true>
>
> The above API call will give first 1000 TEI ids because the call is
> paginated with pagesize=1000. Like that we are making calls for other pages
> to fetch all the TEI Ids.
>
> DHIS is using the below query to get the TEI ids
>
> select distinct tei from TrackedEntityInstance tei left join tei.trackedEntityAttributeValues
> where (  tei.organisationUnit.path LIKE '/a2cf79e8g34/a1c343a3w24%') and  tei.deleted
> is false;
>
> In this query we couldn't find any order by clause. Is there any chance
> that few of the TEI ids which are returned in some page are going to be
> repeated in another page also.
> Is this query going to be executed every time for each paginated API call?
>
> --
> Rajeswari Gottipati
> Sr Consultant
> Email rajeswag@xxxxxxxxxxxxxxxx
> Telephone +91 9949292931 <+91%209949292931>
> [image: ThoughtWorks]
> <http://www.thoughtworks.com/?utm_campaign=rajeswari-gottipati-signature&utm_medium=email&utm_source=thoughtworks-email-signature-generator>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dhis2-devs
> Post to     : dhis2-devs@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~dhis2-devs
> More help   : https://help.launchpad.net/ListHelp
>
>

Follow ups

References