Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unneeded group bys from time spine dataset #1453

Merged
merged 3 commits into from
Oct 10, 2024

Conversation

courtneyholcomb
Copy link
Contributor

@courtneyholcomb courtneyholcomb commented Oct 10, 2024

We've been applying an unnecessary group by to the time spine dataset. Previously, we were applying group bys whenever a DATE_TRUNC column was included in the select statement, even if the base grain was included in the select statement. These group bys are unnecessary, because If there is no DATE_TRUNC applied to one select column, then none of the columns will be changed by the group by. For example:

SELECT
  ds
  , DATE_TRUNC(ds, month)
FROM time_spine
GROUP BY
  ds, DATE_TRUNC(ds, month)

will return the same result as:

SELECT
  ds
  , DATE_TRUNC(ds, month)
FROM time_spine

The results are the same, but the first query is inefficient because of the unnecessary group by. This PR removes the unnecessary group bys.
Note that if the base grain is not included, the group by is still necessary.

I recommend reviewing by commit because the number of snapshot changes is very large.

@cla-bot cla-bot bot added the cla:yes label Oct 10, 2024
Copy link
Contributor

@DevonFulcher DevonFulcher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I'm curious, why two changelogs? Also, this is meant to improve data warehouse query-time performance, right? Not MF parse-time performance?

@courtneyholcomb
Copy link
Contributor Author

Nice! I'm curious, why two changelogs? Also, this is meant to improve data warehouse query-time performance, right? Not MF parse-time performance?

@DevonFulcher whoops, I added a new changelog this morning after seeing the GitHub comment saying I needed one, not remembering that I already added one yesterday 😂 will remove the new one
And yes! The group by would slow down the query in the warehouse. This isn't part of the performance improvement project, it's just something I found while working on a different bug fix.

@courtneyholcomb courtneyholcomb merged commit 10138b0 into main Oct 10, 2024
19 checks passed
@courtneyholcomb courtneyholcomb deleted the court/ts-filter1 branch October 10, 2024 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants