DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • Data Exploration Using Serverless SQL Pool In Azure Synapse
  • Which Tool Is Better for Code Completion — Azure Data Studio or dbForge SQL Complete?
  • How to Generate Customer Success Analytics in Snowflake
  • Using Datafold to Enhance DBT for Data Observability

Trending

  • Agile’s Quarter-Century Crisis
  • Enforcing Architecture With ArchUnit in Java
  • How to Use AWS Aurora Database for a Retail Point of Sale (POS) Transaction System
  • GitHub Copilot's New AI Coding Agent Saves Developers Time – And Requires Their Oversight
  1. DZone
  2. Data Engineering
  3. Data
  4. Scheduling Statistics Maintenance in Azure SQL Data Warehouse

Scheduling Statistics Maintenance in Azure SQL Data Warehouse

You can leverage your Azure SQL Data Warehouse to automate some of your maintenance. Creating a Runbook will let you schedule to your hearts content.

By 
Grant Fritchey user avatar
Grant Fritchey
·
Jan. 23, 17 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
4.2K Views

Join the DZone community and get the full member experience.

Join For Free

the power and capabilities of azure sql data warehouse are pretty amazing. however, it’s still basically sql server under the covers. sql server still needs maintenance and one type of maintenance is keeping statistics up to date. statistics maintenance is doubly important within azure sql data warehouse because statistics are not created automatically, nor are they maintained automatically. it’s up to you to ensure your statistics are up to date.

statistics in azure sql data warehouse

it’s worth re-emphasizing the point that there is no automatic creation of statistics in azure sql data warehouse. this means you need to plan to add statistics to your tables. microsoft recommends an easy method is to add them to every column. while that does make things easy, it’s not like statistics are free. if you add them to every column, you’ll also have to maintain them, on every column. that could be costly. i’d rather see a targeted approach, but that will require additional work and a good understanding of how the data warehouse is being used. that’s not always possible, hence microsoft’s suggestion. your methods of data loading to your warehouse are also going to drive your statistics maintenance routines. it’s a complex dance that goes beyond the scope of this blog post. to read more about what microsoft has to say about statistics in azure sql data warehouse, read this article .

automating maintenance

because we’ve moved into a platform as a service (paas) offering with azure sql data warehouse, we don’t have the types of automation mechanisms we’re accustomed to. by that i mean, there is no sql agent. instead, we have azure automation:

image title

i have an azure sql data warehouse i’m using for teaching this topic while on sql cruise . let’s go ahead and add an automation account:

image title


note : the most important habit you can start within azure is putting everything into discrete, planned, resource groups. these make management so much easier.

once the account is set, the first thing you need is to create a runbook. there is a collection of them for your use within azure. none of them are immediately applicable for what i need. i’m just writing a really simple powershell script to do what i want:

$sqlusername = 'grant'
$sqlpwd = 'xxx'
 
# define the connection to the sql database
$conn = new-object system.data.sqlclient.sqlconnection("server=tcp:cruise2017.database.windows.net;database=cruisers;user id=$sqlusername;password=$sqlpwd;trusted_connection=false;encrypt=true;connection timeout=30;")
         
# open the sql connection
$conn.open()
 
# define the sql command to run. in this case we are getting the number of rows in the table
$cmd=new-object system.data.sqlclient.sqlcommand("update statistics dbo.dimreseller", $conn)
 
# execute the sql command
$cmd.executenonquery()
 
# close the sql connection
$conn.close()


nothing to it. yes, for a production system, you’ll want to be able to loop through all your tables, pick and choose which statistics get updated, etc. i’ll leave that to you to figure out for your system. it’s straightforward stuff.

note : thanks to denny cherry and mike fal for some pointers on troubleshooting setting this up. there’s a test pane that you need to make liberal use of along with write-output commands in order to identify where things are going south.

with the runbook complete, save it, and publish it:

image title


scheduling automation

once i’ve published my runbook, i can simply click on the schedule button in order to decide when i want it to run:

image title

obviously, you can pretty easily set up the schedule in all the standard methods available to you in sql agent. once this is done, you’re all set. you’ve just successfully created a schedule for updating statistics in azure sql data warehouse.

conclusion

while a long discussion can be had around when and where you need to create statistics inside azure sql data warehouse, there is no doubt that you will need to update those statistics. it can be just simply a part of your load process. however, if you have a trickle load, or nightly updates, you’ll want to explore using azure automation to make that happen.

sql Data warehouse Statistics azure Data (computing) Scheduling (computing)

Published at DZone with permission of Grant Fritchey, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Data Exploration Using Serverless SQL Pool In Azure Synapse
  • Which Tool Is Better for Code Completion — Azure Data Studio or dbForge SQL Complete?
  • How to Generate Customer Success Analytics in Snowflake
  • Using Datafold to Enhance DBT for Data Observability

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!