Necessary Evils, Building Optimized
CRUD Procedures
Introduction
Jason
Strate

e: jstrate@pragmaticworks.com
e: jasonstrate@gmail.com
b: www.jasonstrate.com
t: StrateSQL

Resources

jasonstrate.com

MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
About Pragmatic Works

•

•
•
•
•

•
•

Industry leaders in Microsoft BI and SQL Server
Platform
SQL Server Professionals - PASS Board of Directors,
Speakers, Authors and MVP’s
National Sales Team Divided by Microsoft
Territories
National System Integrator (NSI)
Gold Certified in Business Intelligence and Data
Platform
Platform Modernization/Safe Passage
Premier Partner for PDW SI Partner Program
MS PDW Partner of Year FY13
Frontline Partnership Partner of the Year for Big Data
Executive sponsor - Andy Mouacdie, WW sales director
PDW

•
•

Over 7,200 customers worldwide
Over 186,000 people in PW database for demand
generation
MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
Session Goals
1. Describe the uses for CRUD procedures in
databases
2. Identify the common problems associated with
CRUD procedures
3. Demonstrate methods for writing performant
CRUD procedures

MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
What is CRUD?
CREATE, READ, UPDATE, DELETE
•
•
•
•
•
•

ABCD: add, browse, change, delete
BREAD: browse, read, edit, add, delete
QDIM: query, delete, insert, modify
SAID: show, alter, insert, delete
VEDAS: view, edit, delete, add, search
VADE(R): view, add, delete, edit

MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
Code Generation
• Many tools available:
– T-SQL Script
– Code Smith
– Entity Framework
– LINQ to SQL
– NHibernate

MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
CRUD Issues?
• Treat tables as objects
–
–
–

People?
Relationships?
Relationship Type?

• Overly generic
– All columns touched
– One procedure to rule them all

• Performance
– Set versus Singleton
– Index selection
MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
Perspectives

MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
Overview

CREATE, UPDATE, AND DELETE

MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
CREATE
CREATE = INSERT
EXEC CRUD.FooInsert
@Column1 = 'Value‘,
@Column2 = 2

INSERT INTO dbo.Foo
(Column1, Column2)
VALUES(@Column1,
@Column2)

Issues:
• Singleton insert
• All columns affected
MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
UPDATE
UPDATE = UPDATE
EXEC CRUD.FooUpdate
@Column1 = 'Value‘,
@Column2 = 2

UPDATE dbo.Foo
SET Column1 = @Column1
WHERE Column2 =
@Column2

Issues:
Singleton update
All columns affected
MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
DELETE
DELETE = DELETE
EXEC CRUD.FooDelete
@Column2 = 2

DELETE FROM dbo.Foo
WHERE Column2 = Column2

Issues:
• Singleton delete

MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
T-SQL Features
• Performance
– Table Valued Functions (TVF)
– Table Valued Parameters (TVP)
– XML document
– Merge statement

MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
Demos

CREATE, UPDATE, AND DELETE

MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
Overview

READ

MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
READ
• READ = SELECT
EXEC CRUD.FooSelect
@Column1 = NULL
,@Column2 = 2

SELECT Column1
,Column2
FROM dbo.Foo
WHERE (@Column1 IS NULL
OR Column1 = @Column1)
AND (@Column2 IS NULL
OR Column2 = @Column2)

Issues
• Index selectivity
MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
Demo

READ

MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
Summary
1. CRUD isn’t necessarily bad
2. Generic templates offer ability to tune and
extend data model behind the scenes.
3. Be cautious in choosing a template for CRUD
4. Know what SQL Server is doing
5. Leverage RECOMPILE as needed

MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
Learn More About Performance

MAKING BUSINESS INTELLIGENT

www.pragmaticworks.com
For more information…
Name: Jason Strate
Email: jstrate@pragmaticworks.com
Blog: www.jasonstrate.com

Products
BI products to covert to a Microsoft BI
platform and simplify development on
the platform.

Services
Speed development through training, and
rapid development services from
Pragmatic Works.

Foundation
Helping those who do not have the
means to get into information technology
achieve their dreams.

More Related Content

PDF
The Flavors of Non-Clustered Indexes
PDF
How Do Non-Clustered Indexes Improve Performance?
PDF
Introduction to Clustered Indexes and Heaps
PPTX
2013 SPSDC Reston - Getting Started with Office 365
PPTX
Spsnyc 2016 JSLink Primer
PPTX
SEO optimization at Maxpho ecommerce and marketplaces
PDF
Getting Started with Windows Azure and SQL Databases
PDF
Leveraging Cloud for the Modern SQL Developer
The Flavors of Non-Clustered Indexes
How Do Non-Clustered Indexes Improve Performance?
Introduction to Clustered Indexes and Heaps
2013 SPSDC Reston - Getting Started with Office 365
Spsnyc 2016 JSLink Primer
SEO optimization at Maxpho ecommerce and marketplaces
Getting Started with Windows Azure and SQL Databases
Leveraging Cloud for the Modern SQL Developer

Similar to Necessary Evils, Building Optimized CRUD Procedures (20)

PDF
Introduction to Columnstore Indexes
PDF
Choosing Your Clustered Index
PPTX
Testing Database Changes
PPTX
Web Developer make the most out of your Database !
PDF
5 ways to improve performance through indexing
PDF
Sql For Ibm I A Database Modernization Guide None Rafael Victriapereira
DOC
Subqueries views stored procedures_triggers_transactions
PPTX
Training on Microsoft SQL Server(older version).pptx
PDF
Session 1 - Databases-JUNE 2023.pdf
PPTX
Physical Design and Development
PPTX
Sql good practices
PPT
demo2.ppt
PDF
Oracle
PPTX
Understanding the Value of Database Discovery - Beyond Unstructured Data
PPT
asdasdasdasdsadasdasdasdasdsadasdasdasdsadsadasd
PDF
Sql coding-standard-sqlserver
PDF
PDF
Database development coding standards
PPT
SQL Inteoduction to SQL manipulating of data
PDF
Intruduction to SQL.Structured Query Language(SQL}
Introduction to Columnstore Indexes
Choosing Your Clustered Index
Testing Database Changes
Web Developer make the most out of your Database !
5 ways to improve performance through indexing
Sql For Ibm I A Database Modernization Guide None Rafael Victriapereira
Subqueries views stored procedures_triggers_transactions
Training on Microsoft SQL Server(older version).pptx
Session 1 - Databases-JUNE 2023.pdf
Physical Design and Development
Sql good practices
demo2.ppt
Oracle
Understanding the Value of Database Discovery - Beyond Unstructured Data
asdasdasdasdsadasdasdasdasdsadasdasdasdsadsadasd
Sql coding-standard-sqlserver
Database development coding standards
SQL Inteoduction to SQL manipulating of data
Intruduction to SQL.Structured Query Language(SQL}
Ad

More from Jason Strate (14)

PPTX
Accelerating Business Intelligence Solutions with Microsoft Azure pass
PPTX
The Plan Cache Whisperer - Performance Tuning SQL Server
PDF
Strategies for SQL Server Index Analysis
PDF
5 SQL Server Indexing Myths
PDF
BuildingSecurity Audits with Extended Events
PDF
5 Amazing Reasons DBAs Need to Love Extended Events
PPTX
The Side Effect of NOLOCK
PDF
Discovering the plan cache (sql sat175)
PDF
Introduction to SQL Server Security
PDF
What are you waiting for? (#SQLSat211)
PDF
Discovering the plan cache (#SQLSat211)
PDF
Discovering the Plan Cache (#SQLSat 206)
PDF
A Function by Any Other Name is a Function
PDF
What are you waiting for
Accelerating Business Intelligence Solutions with Microsoft Azure pass
The Plan Cache Whisperer - Performance Tuning SQL Server
Strategies for SQL Server Index Analysis
5 SQL Server Indexing Myths
BuildingSecurity Audits with Extended Events
5 Amazing Reasons DBAs Need to Love Extended Events
The Side Effect of NOLOCK
Discovering the plan cache (sql sat175)
Introduction to SQL Server Security
What are you waiting for? (#SQLSat211)
Discovering the plan cache (#SQLSat211)
Discovering the Plan Cache (#SQLSat 206)
A Function by Any Other Name is a Function
What are you waiting for
Ad

Recently uploaded (20)

PDF
WOOl fibre morphology and structure.pdf for textiles
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
PDF
Zenith AI: Advanced Artificial Intelligence
PPTX
The various Industrial Revolutions .pptx
PPTX
Chapter 5: Probability Theory and Statistics
PDF
A comparative study of natural language inference in Swahili using monolingua...
PPTX
Web Crawler for Trend Tracking Gen Z Insights.pptx
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPT
What is a Computer? Input Devices /output devices
PPT
Module 1.ppt Iot fundamentals and Architecture
PDF
A novel scalable deep ensemble learning framework for big data classification...
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PDF
Developing a website for English-speaking practice to English as a foreign la...
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PDF
Enhancing emotion recognition model for a student engagement use case through...
PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PDF
August Patch Tuesday
WOOl fibre morphology and structure.pdf for textiles
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
Zenith AI: Advanced Artificial Intelligence
The various Industrial Revolutions .pptx
Chapter 5: Probability Theory and Statistics
A comparative study of natural language inference in Swahili using monolingua...
Web Crawler for Trend Tracking Gen Z Insights.pptx
Assigned Numbers - 2025 - Bluetooth® Document
What is a Computer? Input Devices /output devices
Module 1.ppt Iot fundamentals and Architecture
A novel scalable deep ensemble learning framework for big data classification...
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
Developing a website for English-speaking practice to English as a foreign la...
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
Enhancing emotion recognition model for a student engagement use case through...
DP Operators-handbook-extract for the Mautical Institute
1 - Historical Antecedents, Social Consideration.pdf
NewMind AI Weekly Chronicles – August ’25 Week III
August Patch Tuesday

Necessary Evils, Building Optimized CRUD Procedures

  • 1. Necessary Evils, Building Optimized CRUD Procedures
  • 2. Introduction Jason Strate e: [email protected] e: [email protected] b: www.jasonstrate.com t: StrateSQL Resources jasonstrate.com MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  • 3. About Pragmatic Works • • • • • • • Industry leaders in Microsoft BI and SQL Server Platform SQL Server Professionals - PASS Board of Directors, Speakers, Authors and MVP’s National Sales Team Divided by Microsoft Territories National System Integrator (NSI) Gold Certified in Business Intelligence and Data Platform Platform Modernization/Safe Passage Premier Partner for PDW SI Partner Program MS PDW Partner of Year FY13 Frontline Partnership Partner of the Year for Big Data Executive sponsor - Andy Mouacdie, WW sales director PDW • • Over 7,200 customers worldwide Over 186,000 people in PW database for demand generation MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  • 4. Session Goals 1. Describe the uses for CRUD procedures in databases 2. Identify the common problems associated with CRUD procedures 3. Demonstrate methods for writing performant CRUD procedures MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  • 5. What is CRUD? CREATE, READ, UPDATE, DELETE • • • • • • ABCD: add, browse, change, delete BREAD: browse, read, edit, add, delete QDIM: query, delete, insert, modify SAID: show, alter, insert, delete VEDAS: view, edit, delete, add, search VADE(R): view, add, delete, edit MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  • 6. Code Generation • Many tools available: – T-SQL Script – Code Smith – Entity Framework – LINQ to SQL – NHibernate MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  • 7. CRUD Issues? • Treat tables as objects – – – People? Relationships? Relationship Type? • Overly generic – All columns touched – One procedure to rule them all • Performance – Set versus Singleton – Index selection MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  • 9. Overview CREATE, UPDATE, AND DELETE MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  • 10. CREATE CREATE = INSERT EXEC CRUD.FooInsert @Column1 = 'Value‘, @Column2 = 2 INSERT INTO dbo.Foo (Column1, Column2) VALUES(@Column1, @Column2) Issues: • Singleton insert • All columns affected MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  • 11. UPDATE UPDATE = UPDATE EXEC CRUD.FooUpdate @Column1 = 'Value‘, @Column2 = 2 UPDATE dbo.Foo SET Column1 = @Column1 WHERE Column2 = @Column2 Issues: Singleton update All columns affected MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  • 12. DELETE DELETE = DELETE EXEC CRUD.FooDelete @Column2 = 2 DELETE FROM dbo.Foo WHERE Column2 = Column2 Issues: • Singleton delete MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  • 13. T-SQL Features • Performance – Table Valued Functions (TVF) – Table Valued Parameters (TVP) – XML document – Merge statement MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  • 14. Demos CREATE, UPDATE, AND DELETE MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  • 16. READ • READ = SELECT EXEC CRUD.FooSelect @Column1 = NULL ,@Column2 = 2 SELECT Column1 ,Column2 FROM dbo.Foo WHERE (@Column1 IS NULL OR Column1 = @Column1) AND (@Column2 IS NULL OR Column2 = @Column2) Issues • Index selectivity MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  • 18. Summary 1. CRUD isn’t necessarily bad 2. Generic templates offer ability to tune and extend data model behind the scenes. 3. Be cautious in choosing a template for CRUD 4. Know what SQL Server is doing 5. Leverage RECOMPILE as needed MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  • 19. Learn More About Performance MAKING BUSINESS INTELLIGENT www.pragmaticworks.com
  • 20. For more information… Name: Jason Strate Email: [email protected] Blog: www.jasonstrate.com Products BI products to covert to a Microsoft BI platform and simplify development on the platform. Services Speed development through training, and rapid development services from Pragmatic Works. Foundation Helping those who do not have the means to get into information technology achieve their dreams.