{"id":23885990,"url":"https://github.com/dpguthrie/stored-proc-dbt-demo","last_synced_at":"2025-08-08T10:45:10.071Z","repository":{"id":254368214,"uuid":"846325911","full_name":"dpguthrie/stored-proc-dbt-demo","owner":"dpguthrie","description":"Compare performance of dbt to stored procedures","archived":false,"fork":false,"pushed_at":"2024-08-24T14:45:35.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-23T03:28:51.616Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dpguthrie.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-23T01:15:33.000Z","updated_at":"2024-08-24T14:45:37.000Z","dependencies_parsed_at":"2024-08-23T02:31:18.040Z","dependency_job_id":"6201ea01-e48b-44b2-8ed0-cf219000c7cb","html_url":"https://github.com/dpguthrie/stored-proc-dbt-demo","commit_stats":null,"previous_names":["dpguthrie/stored-proc-dbt-demo"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dpguthrie/stored-proc-dbt-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dpguthrie%2Fstored-proc-dbt-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dpguthrie%2Fstored-proc-dbt-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dpguthrie%2Fstored-proc-dbt-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dpguthrie%2Fstored-proc-dbt-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dpguthrie","download_url":"https://codeload.github.com/dpguthrie/stored-proc-dbt-demo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dpguthrie%2Fstored-proc-dbt-demo/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269410043,"owners_count":24412146,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-08T02:00:09.200Z","response_time":72,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-04T05:56:18.058Z","updated_at":"2025-08-08T10:45:10.036Z","avatar_url":"https://github.com/dpguthrie.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dbt to Stored Proc (Snowflake)\n\nThe purpose of this repo is to demonstrate the benefit of using dbt over a stored procedure, specifically from a performance perspective (there's a lot more we can get into but we'll save that for another day).\n\ndbt has a concept of [threads](https://docs.getdbt.com/docs/running-a-dbt-project/using-threads), which means that dbt can work on up to n number of nodes (models, tests, snapshots) at once without violating the pipeline's dependencies.  Said another way, dbt can run things in parallel when the DAG allows it.\n\nContrast that with a stored procedure approach, which does things in a sequential manner from top to bottom, this becomes a pretty easy exercise in demonstrating cost savings in your warehouse.\n\n## Instructions\n\n1. Delete your log file (if it exists).  This will be found at `logs/dbt.log` unless you've changed the configuration within your `dbt_project.yml` file.\n\n2. Run a dbt command.  The command should run a good portion of your project (or even all of it!).  The more you run, the more cost savings that you'll be able to demonstrate.\n\n```bash\ndbt build -s +fct_order_items+\n```\n\n**Note the time it took to run this command - you'll need it later to compare to the stored procedure!**\n\n3. Run the script in this repo from the root of your dbt project:\n\n```bash\npython log_to_proc.py\n```\n\nIf you've changed the location of your log file, pass that as a flag when running the script:\n\n```bash\npython log_to_proc.py --log-path my_logs/dbt.log\n```\n\n4. Copy/paste the code output from `stored_proc.sql` into your Snowflake Editor and execute all of the statements.  Take note of the time it takes to run your stored procedure.\n\n**The output to the .sql file contains code to set the `USE_CACHED_RESULT` to `FALSE` so that the stored procedure is run without any of the cached results from the prior dbt run.**\n\n5. Now compare!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdpguthrie%2Fstored-proc-dbt-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdpguthrie%2Fstored-proc-dbt-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdpguthrie%2Fstored-proc-dbt-demo/lists"}