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

Deduplicate postgres relations (#3058) #4521

Merged
merged 6 commits into from
Feb 21, 2022
Merged

Deduplicate postgres relations (#3058) #4521

merged 6 commits into from
Feb 21, 2022

Conversation

netbek
Copy link
Contributor

@netbek netbek commented Dec 20, 2021

Fixes #3058

Description

Removes duplicate dependencies in order to speed up postgres_get_relations query. I've tested in Postgres 14 with a newly restored database and a basic dbt model (view materialization) that hadn't been materialized yet. I ran dbt docs generate and checked the log timestamps to confirm that the slowdown was caused by this query. The relations consist of 3 views and 11 tables in the same schema. Without the fix applied, 82 rows are returned and it takes ~16 s. With the fix applied, 14 rows are returned and it takes ~80 ms. Best of 3 runs. I removed the GROUP BY clause from the primary query to check this.

I'm not able to share this database. Regardless, I think it would be too complicated for a test.

Checklist

  • I have signed the CLA
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • I have updated the CHANGELOG.md and added information about my change

@cla-bot cla-bot bot added the cla:yes label Dec 20, 2021
@jtcohen6 jtcohen6 added the Team:Adapters Issues designated for the adapter area of the code label Jan 4, 2022
@netbek netbek requested a review from a team as a code owner February 6, 2022 04:20
@McKnight-42 McKnight-42 self-requested a review February 6, 2022 06:50
Copy link
Contributor

@McKnight-42 McKnight-42 left a comment

Choose a reason for hiding this comment

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

looks okay to me, the issue is very compelling for changes being made

@McKnight-42
Copy link
Contributor

@netbek reviewed, would like you to go ahead and update to the newest version of main to make sure you have our implementation of the black formatter so those tests can run properly as well if you don't mind. and add your addition to the changelog

@netbek netbek requested a review from a team as a code owner February 19, 2022 11:57
@netbek
Copy link
Contributor Author

netbek commented Feb 19, 2022

@McKnight-42 Thanks for looking at it. I've merged in the most recent main and added a note to the changelog.

@McKnight-42 McKnight-42 merged commit 10b27b9 into dbt-labs:main Feb 21, 2022
@netbek netbek deleted the fix-duplicate-postgres-relations branch March 19, 2022 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes Team:Adapters Issues designated for the adapter area of the code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Macro postgres_get_relations makes dbt run slow
3 participants