forked from openedx/aspects-dbt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Performance: Remove unused models, reduce memory usage (openedx#111)
* refactor!: Remove unused models These models are currently shown as unused in the base project, this usually means they either have performance issues and require prewhere in Superset, or were added with speculation they may be used later but never where. This is a breaking change for anyone who uses these models downstream in a custom dbt project or Superset report, however they can simply be copied wholesale into a downstream dbt project. dbt doesn't delete removed models from the database, so if a running service has those resources they can either be manually dropped or left in place if they are being used. * refactor: Reduce memory usage on dict queries * refactor: Add / use most_recent_course_blocks mv * feat: Add ability to remove deprecated objects from the database.
- Loading branch information
Showing
30 changed files
with
74 additions
and
1,403 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{% macro do_drop(type, schema, relation) %} | ||
-- Drop a relation, types are "view", "table", or "mv". | ||
-- "mv" will drop both the expected view and destination table. | ||
{% if type == "mv" %} | ||
{% do do_drop("view", schema, relation ~ "_mv") %} | ||
{% do do_drop("table", schema, relation) %} | ||
{% else %} | ||
{% set cmd = "drop " ~ type ~ " if exists " ~ schema ~ "." ~ relation ~ ";" %} | ||
{% print(cmd) %} | ||
{% do run_query(cmd) %} | ||
{% endif %} | ||
{% endmacro %} | ||
|
||
{% macro remove_deprecated_models() %} | ||
{% set xapi = env_var("ASPECTS_XAPI_DATABASE", "xapi") %} | ||
{% set reporting = env_var("DBT_PROFILE_TARGET_DATABASE", "reporting") %} | ||
{% set event_sink = env_var("ASPECTS_EVENT_SINK_DATABASE", "event_sink") %} | ||
|
||
{{ | ||
print( | ||
"Running remove_deprecated_models on " | ||
~ xapi | ||
~ ", " | ||
~ reporting | ||
~ ", " | ||
~ event_sink | ||
~ "." | ||
) | ||
}} | ||
|
||
-- https://github.com/openedx/aspects-dbt/pull/111/ | ||
{% do do_drop("mv", xapi, "completion_events") %} | ||
{% do do_drop("view", reporting, "fact_completions") %} | ||
{% do do_drop("view", xapi, "fact_forum_interactions") %} | ||
{% do do_drop("mv", xapi, "forum_events") %} | ||
{% do do_drop("view", reporting, "fact_grades") %} | ||
{% do do_drop("view", reporting, "learner_summary") %} | ||
{% do do_drop("view", reporting, "fact_navigation_dropoff") %} | ||
{% do do_drop("view", reporting, "fact_learner_problem_summary") %} | ||
{% do do_drop("view", reporting, "fact_problem_engagement") %} | ||
{% do do_drop("view", reporting, "fact_problem_engagement_per_subsection") %} | ||
{% do do_drop("view", reporting, "fact_problem_responses_extended") %} | ||
{% do do_drop("view", reporting, "dim_at_risk_learners") %} | ||
{% do do_drop("view", reporting, "fact_transcript_usage") %} | ||
{% do do_drop("view", reporting, "fact_watched_video_segments") %} | ||
{% do do_drop("mv", reporting, "video_transcript_events") %} | ||
|
||
{% endmacro %} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.