Skip to content
Snippets Groups Projects
user avatar
Cam Saul authored
The biggest performance improvement in history of Metabase since we switched to Clojure

Before when filtering by a "bucketed" datetime field we would wrap the field and the value(s) it was being compared against in casting/truncation functions. For example when compiling a query to find fields where month is September 2019, we previously generated SQL like this:

```sql
SELECT count(*)
FROM public.checkins
WHERE date_trunc('month', CAST(public.checkins.date AS timestamp)) 
    = CAST(timestamp '2019-09-01T00:00:00Z' AS date)
```

As mentioned in #4043, this is not good for performance! Metabase now generates logically equivalent SQL like

```sql
SELECT count(*)
FROM public.checkins 
WHERE (
    public.checkins.date >= timestamp '2019-09-01T00:00:00Z' AND
    public.checkins.date < timestamp '2019-10-01T00:00:00Z'
)
```

Fixes #4043
Fixes #11009 
Fixes #11010
Fixes #11011 
Fixes #11012
Fixes #11013

:open_mouth: :race_car: 
ceddd03e
History
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
Name Last commit Last update
..
src