page59
41
Approach
You could simply run queries against
SNOWFLAKE_SAMPLE_DATA
using the
ACCOUNTADMIN
role. There are no special tuning optimizations for using the
ACCOUNTADMIN
role, but
I prefer to develop my code as if it were to be deployed into production regardless of
whether I throw the code away or retain it for later use.
I strongly encourage new developers to treat all code as if it were going to be
reviewed and tested for production, and part of my approach is to insist on properly
formatted and commented code. I prefer keywords to shout at me and for all other
words to be in lowercase. Some people agree, others disagree, and everyone is entitled to
their view.
Regardless, you will reuse some code as you progress through this book, so let’s
assume you are aiming for a production release. More will be revealed later as you
progress through the chapters.
Setup
Using the new worksheet, let’s create an environment in which to develop the code
and build components for later reuse. You will start with creating a database, several
warehouses, and a role, and then you will enable access to the Account Usage Store.
you will reuse the environment you are about to create throughout this book.
Snowflake makes reference to the Account Usage Store, which is the imported share
visible within the database share referred to as SNOWFLAKE. Figure 3-1 shows this
imported database above SNOWFLAKE_SAMPLE_DATA.
As SNOWFLAKE_SAMPLE_DATA is an imported share, you cannot modify the
contents. To investigate the query profiler, let’s create an environment for which you also
supply an accompanying script.
You will first declare identifiers to be used throughout this chapter. Note that you
may need to rerun these declarations when you open the browser session again.
SET tpc_owner_role = 'tpc_owner_role';
SET tpc_warehouse_XS = 'tpc_wh_xsmall';
SET tpc_warehouse_S = 'tpc_wh_small';
ChapTer 3
The Query profiler