Problem Description / Requirement

This – simplified – problem arises from software that allows for individual customization to meet customer needs.

A customer uses the software as a grading system for students at their university. A separate column has been implemented in the grade table for each subject. Students use a web interface where they can access their grades. For each exam day, the BEST grade and WORST grade should be displayed in addition to the actual grades. For this purpose, the software company has created a view [dbo].[exam_grades] that is called by the web server. This view returns for each student for each exam day the best and the worst grades.

Challenge

Very high CPU usage is observed, especially in the days following the publication of grades. The problem has been identified in the [dbo].[exam_grades] view.

The dean of the university is contacting you to rewrite the view so that CPU load does not increase significantly with a high number of calls and other program modules can continue to be used as usual.

Condition

  • Rewrite the view
  • The metadata of the table must NOT be changed!
Technical Information

The challenge creates three objects in your database:

  • Table [dbo].[students] with 1,000 rows
  • Table [dbo].[student_exam_grades] with ~350,000 rows
  • View [dbo].[exam_grades
How to start the challenge

When you are connected to the SQL Server instance, run the following commands:

EXECUTE sqlchallenge.dbo.create_challenge 'list';
will give you a list of open challenges
EXECUTE sqlchallenge.dbo.create_challenge 'SQL Challenge #7 - Analysis in denormalized table(s)';
will create the challenge for you

 

customer expectations

The customer wants the view [dbo].[exam_grades] to be rewritten so that the loads on the day the grades are published do not burden other modules of the system.

Connect to Microsoft SQL Server

SQL Server: sqlchallenges.germanywestcentral.cloudapp.azure.com
Port: 1433
Version:
16.0.4165.4
Edition: Developer Edition
Authentication Type: SQL Server Authentication
Login Name: sqlchallenge
Password: sqlchallenge#2025!
Encryption Mandatory
Trust Server Certificate: True
 
Improve Your Skills as Query Tuner for SQL Server During this workshop, you’ll gain the expertise and confidence needed to diagnose and fine-tune slow-performing queries, resulting in improved database responsiveness and end-user satisfaction. Whether you’re an experienced database administrator, developer, or data analyst, this workshop will equip you with the knowledge and practical skills to tackle the most challenging query optimization tasks.
Improve your skills as a database developer
Improve Your Skills as a Database Developer for SQL Server In this workshop, we will cover a wide range of topics and techniques that are essential for modern database developers working with SQL Server. From fundamental concepts to advanced best practices, you’ll gain the knowledge and practical experience needed to excel in your role.