DHIS2 Can't finish the analytic in version 2.37.1

Further to Steve’s comment (I’m working on the same issue) - this has to do with Event data.

We have two identical instances, one a production database on 2.36.3 with a set of Analytics tables that successfully generate with no issues with the following stats Event Analytic SQL row counts/sizes:

2017: 19772 rows, 27 MB
2018: 16283 rows, 22 MB
2019: 122133 rows, 165 MB
2020: 255679 rows, 343 MB
2021: 404120 rows, 543 MB
2022: 858 rows, 1904 kB

In the other identical version of the database, where we are testing updates (2.37 or now 2.38), the analytics updates blow up the disk space when the process gets to tables 2020 or 2021. The row counts and sizes from the temp tables during the updates before it blows up the 120GB disk (100 GB free at the beginning of analytics run), are;

2017: 19772 rows, 2820 MB
2018: 16283 rows, 2356 MB
2019: 122133 rows, 17 GB (long time to gen, was orange, then red in pgadmin)
2020: 0, 25 GB (red condition in pgadmin)
2021: 0, 28 GB (red condition in pgadmin)
2022: 0

This implies that the internal queries that are running during analytics generation for events somehow changed between 2.36 and later versions. Could someone provide some pointers on where we might look at (extra event data checks that are picking up errors/corruption of event data???)? One other note - we have a very similar data model in another country with similar types of event data, and that has been updated to 2.37.x and runs analytics without issue.

Cheers.

DH