data-dwh-dbt-project/models/intermediate
Oriol Roqué Paniagua 8a639413f1 Merged PR 2290: Refactor mtd joins to improve performance
Refactor mtd joins to improve performance, as stated in the ticket:

We noticed that some of the new models for MTD purposes (KPIs reporting) take quite a bit of time to run some simple joins.

The main reason is that there's a double join that can be simplified. The current state is:

```
from int_dates_mtd d
        inner join
            sometable t
            on extract(year from t.table_date) = d.year
            and extract(month from t.table_date) = d.month
            and extract(day from t.table_date) <= d.day
```

and it can be changed to:

```
from int_dates_mtd d
        inner join
            sometable t
            ​on date_trunc('month', t.table_date)::date = d.first_day_month
            and extract(day from t.table_date) <= d.day
```

which is way faster, and keeps the same computation

Related work items: #18330
2024-07-12 12:53:00 +00:00
..
core Merged PR 2290: Refactor mtd joins to improve performance 2024-07-12 12:53:00 +00:00
cross Merged PR 2290: Refactor mtd joins to improve performance 2024-07-12 12:53:00 +00:00
xero Merged PR 2284: KPIs: computing invoicing metrics from Xero 2024-07-12 10:05:49 +00:00