How to query all event IDs under program ID

My dhis2 version is 2.41.0

The event table in my pgsql database is 130G.

I have a requirement now.

I want to query all event IDs under program ID AaDabrz4DXI through the following api

/api/40/tracker/events?fields=program,programStage,enrollment,trackedEntity,event&program=AaDabrz4DXI&page=1&pageSize=1200&ouMode=ALL

However, because there is no index of programstageid in the event table, the query is very slow or even cannot be found. Is there a way to get event ID through program ID without adding index?


Hi @tang765502921

I was able to process the API request on play successfully; however, I changed the page-1&pageSize=1200 to ‘paging=false’ and it returned over 19999+ event IDs. Please see GIF below which takes only a few seconds:
chrome_moGvXrpx1C