{"id":796,"date":"2025-10-24T08:52:01","date_gmt":"2025-10-24T08:52:01","guid":{"rendered":"https:\/\/datadandies.nl\/?p=796"},"modified":"2025-10-24T08:53:26","modified_gmt":"2025-10-24T08:53:26","slug":"how-to-work-with-slow-views-in-snowflake","status":"publish","type":"post","link":"https:\/\/datadandies.nl\/index.php\/2025\/10\/24\/how-to-work-with-slow-views-in-snowflake\/","title":{"rendered":"How to work with slow views in Snowflake"},"content":{"rendered":"\n<p class=\"has-d-4-d-4-d-4-color has-text-color\">Sometimes you are stuck with a slow view in Snowflake. Imagine this scenario:<\/p>\n\n\n\n<p class=\"has-d-4-d-4-d-4-color has-text-color\">You&#8217;re trying to create an object with a slowpoke view as the source and development is as slow as taking the highway at 8 AM to work. <\/p>\n\n\n\n<p class=\"has-d-4-d-4-d-4-color has-text-color\">You cannot edit and improve the view because it is a secure, shared object. The owner of the view is too busy cutting his toenails so no help will be forthcoming from that front. <\/p>\n\n\n\n<p class=\"has-d-4-d-4-d-4-color has-text-color\">Bottom line, you&#8217;re stuck having to deal with this view that takes ages to show you the result of each iteration of your development efforts. <\/p>\n\n\n\n<p class=\"has-d-4-d-4-d-4-color has-text-color\">Is all hope lost? No, I tell thee!<\/p>\n\n\n\n<p class=\"has-d-4-d-4-d-4-color has-text-color\">One way to speed up your development is to create a temporary table from the view. <\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro padding-bottom-disabled cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:1.3rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * 1.3rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e\"><span style=\"background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e\">SQL<\/span><\/span><span role=\"button\" tabindex=\"0\" data-code=\"CREATE TABLE SUPER_FAST_TABLE \n  AS \nSELECT * FROM SLOWPOKE_VIEW\n;\" style=\"color:#D4D4D4;display:none\" aria-label=\"Kopieer\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #569CD6\">CREATE<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">TABLE<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #DCDCAA\">SUPER_FAST_TABLE<\/span><span style=\"color: #D4D4D4\"> <\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">  <\/span><span style=\"color: #569CD6\">AS<\/span><span style=\"color: #D4D4D4\"> <\/span><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">SELECT<\/span><span style=\"color: #D4D4D4\"> * <\/span><span style=\"color: #569CD6\">FROM<\/span><span style=\"color: #D4D4D4\"> SLOWPOKE_VIEW<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">;<\/span><\/span><\/code><\/pre><span style=\"display:flex;align-items:flex-end;padding:10px;width:100%;justify-content:flex-end;background-color:#1E1E1E;color:#c7c7c7;font-size:12px;line-height:1;position:relative\">SQL<\/span><\/div>\n\n\n\n<p>Now, why does this work?<\/p>\n\n\n\n<p>A view is basically a stored SQL query. If this query has a lot of expensive operations, like complex JOINs, filters, etc. it will be slow. <\/p>\n\n\n\n<p>Every time you use the view in a query that you are modifying, all the underlying slow operations have to be performed from scratch. <\/p>\n\n\n\n<p>When you create a table from this view, those slow operations do not have to be performed anymore, because the result is materialized as a table. Snowflake stores the table and you can leverage performance enhancing techniques as micro-partitioning, clustering, pruning, etc. <\/p>\n\n\n\n<p>In short, part of the reasons why this works are detailed below:<\/p>\n\n\n\n<p>SELECT * FROM SLOWPOKE_VIEW WHERE COLUMN1 = &#8216;THIS&#8217; <\/p>\n\n\n\n<p>\u2192 All the slow operations have to be performed (complex JOINs, filters, aggregations, etc.)<\/p>\n\n\n\n<p>\u2192 Result of the query<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>SELECT * FROM SUPER_FAST_TABLE WHERE COLUMN1 = &#8216;THIS&#8217;<\/p>\n\n\n\n<p>\u2192 Result of the query<\/p>\n\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\"><\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\"><\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\"><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you are stuck with a slow view in Snowflake. Imagine this scenario: You&#8217;re trying to create an object with a slowpoke view as the source and development is as slow as taking the highway at 8 AM to work. You cannot edit and improve the view because it is a secure, shared object. The&hellip;<\/p>\n<p class=\"more-link\"><a href=\"https:\/\/datadandies.nl\/index.php\/2025\/10\/24\/how-to-work-with-slow-views-in-snowflake\/\" class=\"themebutton\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[40,4],"class_list":["post-796","post","type-post","status-publish","format-standard","hentry","category-blog","tag-snowflake","tag-sql"],"_links":{"self":[{"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/posts\/796","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/comments?post=796"}],"version-history":[{"count":3,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/posts\/796\/revisions"}],"predecessor-version":[{"id":799,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/posts\/796\/revisions\/799"}],"wp:attachment":[{"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/media?parent=796"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/categories?post=796"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/tags?post=796"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}