← Back to team overview

dhis2-devs team mailing list archive

Re: Missing orderby clause in TrackedEntityInstance Ids query

 

Hi Morten,

Thanks for your inputs. Can you help us understanding how paginated API
calls are going to be handled in DHIS side. For example,

If we make an API call to get first 1000 results i.e page1 -- DHIS will hit
the DB with some query and gives the results (please correct me if I am
wrong here). Will it store the DB query results in-memory?
Subsequently if we make the same API call but for second 1000 i.e page2 --
How DHIS returns the data this time. Will it hit the database again to get
the data or will it get from in-memory?

If we want to add an additional "orderby" clause, is there any parameter in
API to perform sorting or we have to add "orderby" clause in DHIS query.

Thanks,
Rajeswari.


On Thu, Jun 7, 2018 at 12:50 PM, Morten Olav Hansen <morten@xxxxxxxxx>
wrote:

> 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=2
>> 018-06-03&eventStartDate=2018-03-18&fields=trackedEntityInst
>> ance&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
>>
>>
>


-- 
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>

References