# Analytics on Doris: should getDataYears run against the analytics database?

**URL:** <https://community.dhis2.org/t/analytics-on-doris-should-getdatayears-run-against-the-analytics-database/77023>\
**Category:** Support - Assistance technique\
**Tags:** analytics, analytics-tools\
**Created:** [22 September 2026 14:46 UTC](https://community.dhis2.org/t/analytics-on-doris-should-getdatayears-run-against-the-analytics-database/77023 "2026-09-22T14:46:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![diallotafsir52](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/diallotafsir52/32/27283_2.png) [@diallotafsir52](https://community.dhis2.org/u/diallotafsir52)\
**Post date:** [22 September 2026 14:46 UTC](https://community.dhis2.org/t/analytics-on-doris-should-getdatayears-run-against-the-analytics-database/77023/1 "2026-09-22T14:46:56Z")

</div>

Hello,  
We are running DHIS2 2.42 with Apache Doris 3.0.8 as the analytics database, against a PostgreSQL source with a `datavalue` table of about 875 million rows. We are trying to understand one step of the analytics export and would appreciate guidance on whether what we see is expected.

During `ANALYTICS_TABLE`, before any data is written, there is a consistent ~15 minute pause. We traced it to this query in [`JdbcAnalyticsTableManager.getDataYears()`](https://github.com/dhis2/dhis2-core/blob/f8864642c529d7aa85e166533529eeeda18c1542/dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java#L688-L708):

```auto
select distinct(year) from ${datavalue} dv
inner join analytics_rs_periodstructure pes on dv.periodid=pes.periodid
where pes.startdate is not null and dv.lastupdated < '<start time>'

```

Doris reports: 902,621 ms, 875,500,100 rows scanned, 14.1 GB read, **2 rows returned**. Reproduced on a second run at ~14m32s.

The cause appears to be that the two tables end up on opposite sides of the federation boundary. `${datavalue}` is qualified via [`DorisSqlBuilder.qualifyTable()`](https://github.com/dhis2/dhis2-core/blob/f8864642c529d7aa85e166533529eeeda18c1542/dhis-2/dhis-support/dhis-support-sql/src/main/java/org/hisp/dhis/db/sql/DorisSqlBuilder.java#L217-L219) into `pg_dhis.public.datavalue` (PostgreSQL), while `analytics_rs_periodstructure` stays unqualified and resolves to the Doris-native replica. Doris cannot push a join across a JDBC catalog, so it streams the entire external side in. The Doris backend logs the statement it sends to PostgreSQL, and it carries no period restriction:

```auto
SELECT "periodid", "lastupdated" FROM "public"."datavalue"
WHERE ("lastupdated" < '2026-09-22 13:32:00')

```

Our question: both tables in this query exist in the **source** PostgreSQL database. `analytics_rs_periodstructure` is generated there by `JdbcResourceTableStore` and only afterwards copied into Doris by [`replicateAnalyticsResourceTables()`](https://github.com/dhis2/dhis2-core/blob/f8864642c529d7aa85e166533529eeeda18c1542/dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/resourcetable/DefaultResourceTableService.java#L121-L124). But the manager is constructed with [`@Qualifier("analyticsReadOnlyJdbcTemplate")`](https://github.com/dhis2/dhis2-core/blob/f8864642c529d7aa85e166533529eeeda18c1542/dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java#L177), so the query runs on Doris.

Is there a reason `getDataYears` must execute against the analytics database rather than the source one? The result is a list of years, which we would expect to be identical either way. If running it on the source template is safe, it would remove a fixed ~15 minute cost from every analytics run on Doris.

The same shape is present on `master` ([`getDataYears`](https://github.com/dhis2/dhis2-core/blob/b4c510bf3326078fb9d9c438a506709d2a893f31/dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java#L699-L720), with the qualifier renamed to `analyticsJdbcTemplate`), so this does not look like something already fixed.

We are happy to raise this as a Jira issue if that is more useful. Versions: DHIS2 2.42.x, Apache Doris 3.0.8-rc01, PostgreSQL source, `analytics.database = doris`.

---

<div class="post-metadata">

**Author:** ![diallotafsir52](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/diallotafsir52/32/27283_2.png) [@diallotafsir52](https://community.dhis2.org/u/diallotafsir52)\
**Post date:** [22 September 2026 14:48 UTC](https://community.dhis2.org/t/analytics-on-doris-should-getdatayears-run-against-the-analytics-database/77023/2 "2026-09-22T14:48:47Z")

</div>

Hello @Gassim, please do you know who can help on this? adding @tkipkurgat also since he is testing doris.

cc @Kenyuri

---

<div class="post-metadata">

**Author:** ![Gassim](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/gassim/32/35347_2.png) [@Gassim](https://community.dhis2.org/u/Gassim)\
**Post date:** [22 September 2026 20:47 UTC](https://community.dhis2.org/t/analytics-on-doris-should-getdatayears-run-against-the-analytics-database/77023/3 "2026-09-22T20:47:51Z")

</div>

Hi

Thank you for reporting this. Sounds that it’s addressing the same issue reported by @jason here: [Jira](https://dhis2.atlassian.net/browse/DHIS2-21552) ?

Thanks!

---

<div class="post-metadata">

**Author:** ![jason](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/jason/32/32739_2.png) [@jason](https://community.dhis2.org/u/jason)\
**Post date:** [23 September 2026 07:08 UTC](https://community.dhis2.org/t/analytics-on-doris-should-getdatayears-run-against-the-analytics-database/77023/4 "2026-09-23T07:08:02Z")

</div>

We are aware of this problem and are seeking a solution. We have seen it in other places. Tagging @maikel and @luciano
