Refactoring Legacy T-SQL for Improved Performance 1st Edition Lisa Bohm download
Refactoring Legacy T-SQL for Improved Performance 1st Edition Lisa Bohm download
https://ebookmeta.com/product/refactoring-legacy-t-sql-for-
improved-performance-1st-edition-lisa-bohm/
https://ebookmeta.com/product/smart-technologies-for-improved-
performance-of-manufacturing-systems-and-services-1st-edition-
bikash-chandra-behera/
https://ebookmeta.com/product/pro-t-sql-2019-toward-speed-
scalability-and-standardization-for-sql-server-developers-1st-
edition-elizabeth-noble/
https://ebookmeta.com/product/legacy-the-netherworld-
academy-1-1st-edition-lisa-cardwell/
https://ebookmeta.com/product/on-middle-ground-a-history-of-the-
jews-of-baltimore-eric-l-goldstein/
A Dark Matter 1st Edition Doug Johnstone
https://ebookmeta.com/product/a-dark-matter-1st-edition-doug-
johnstone/
https://ebookmeta.com/product/languaging-diversity-
volume-3-language-s-and-power-1st-edition-elena-di-giovanni/
https://ebookmeta.com/product/the-social-life-of-hagiography-in-
the-merovingian-kingdom-kreiner/
https://ebookmeta.com/product/the-school-of-hillah-and-the-
formation-of-twelver-shi-i-islamic-tradition-1st-edition-aun-
hasan-ali/
https://ebookmeta.com/product/savannah-mafia-1-cruel-prince-1st-
edition-m-a-lee/
Kronos Rising Purgatory A Fast Paced Sci Fi Suspense
Thriller Book 6 in the Kronos Rising series 1st Edition
Max Hawthorne
https://ebookmeta.com/product/kronos-rising-purgatory-a-fast-
paced-sci-fi-suspense-thriller-book-6-in-the-kronos-rising-
series-1st-edition-max-hawthorne/
Refactoring
Legacy T-SQL
for Improved
Performance
Modern Practices for SQL Server
Applications
—
Lisa Bohm
www.allitebooks.com
Refactoring Legacy T-SQL
for Improved Performance
Modern Practices for
SQL Server Applications
Lisa Bohm
www.allitebooks.com
Refactoring Legacy T-SQL for Improved Performance: Modern Practices for
SQL Server Applications
Lisa Bohm
Chardon, OH, USA
www.allitebooks.com
This book is dedicated to Allen White, who has been my friend as well as
helped me grow into a valued member of the community, and
taught me how important it is to keep giving back and
helping others.
www.allitebooks.com
Table of Contents
About the Author����������������������������������������������������������������������������������������������������� xi
Introduction�����������������������������������������������������������������������������������������������������������xvii
Chapter 2: Documentation�������������������������������������������������������������������������������������� 21
Incorporating Existing Documentation���������������������������������������������������������������������������������������� 21
Functionality Documentation������������������������������������������������������������������������������������������������� 28
www.allitebooks.com
Table of Contents
vi
Table of Contents
vii
Table of Contents
viii
Table of Contents
Index��������������������������������������������������������������������������������������������������������������������� 233
ix
About the Author
Lisa Bohm leads a team of database administrators (DBAs)
for a software development company. Her history with
legacy database code began early in her career with a
summer project to rewrite the chemical inventory database
for the research division of a local VA hospital. From
there, she went on to building front-end web applications.
When the web calls timed out, Lisa dug in to learn what
databases can do. She has since transitioned into database
administration, inheriting and improving legacy applications
along the way. Her personal focus remains on solid database
architecture and writing well-performing T-SQL.
xi
About the Technical Reviewer
Kathi Kellenberger is a data platform MVP and the editor of Simple Talk at Redgate
Software. She has worked with SQL Server for over 20 years. She is also coleader of the
PASS Women in Technology Virtual Group and an instructor at LaunchCode. In her
spare time, Kathi enjoys spending time with family and friends, singing, and cycling.
xiii
Acknowledgments
I would like to thank all of the people who believed in me, encouraged, and pushed me
to continue to grow and learn. Special thanks go to Mindy Curnutt, Eric Blinn, and Tim
Tarbet, who showed me how amazing someone can be at the job they choose to do, and
believed that I could be that good too.
I cannot leave out the people who work for me. I lead a wonderful team of involved
people who are active in their continued learning, and continue to inspire me every day
by finding solutions to really difficult problems.
Also thank you to my family (including my #sqlfamily) who have always been
supportive, loving, and unstinting of hugs and moral support when needed!
xv
Introduction
What is legacy code? There are a few definitions floating around out there, but as a
working definition, we’re going to use the following:
Legacy code is code that is no longer being actively supported by the people who
wrote it.
Why are we going to use that? In software development, good documentation goes a
long way. Developers should understand what code is trying to accomplish and how it’s
trying to do so. When documentation either doesn’t exist or isn’t as thorough as required
and the original programmers aren’t available if you need to know why something was
written a particular way, it can be a nightmare to fix. In some cases, it may not even
be clear whether code ever worked as intended, or if the functionality of the change
someone is requesting is within the original intent of the programmer(s).
A Tale of Woe
How does legacy code start? Let’s look at this story. Code is written to solve a problem –
for example, someone is copying data into Excel every day and doing some hand
manipulation to generate a graph to add to a larger report. A developer sets up a quick
application to pull the data from the database and export it into Excel automatically for
the user, also performing the calculations the user was doing by hand.
This user then trains their successor and another person in the department on how
to view this report. One of them says, “Hey, this is great! Can you also make it pull data
for this other report and we can show how these numbers reflect against each other?”
Someone else loves the additional functionality but needs the code to work in a different
way, or do different statistical calculations, or needs to add an additional field on the
report. That person’s manager is intrigued by the functionality and wants a weekly
summary report to review. Code structure starts to resemble something that is cobbled
together, as multiple developers add bits of functionality over time. Oftentimes, there
is little to no documentation on the functionality or the choice of code – everyone just
adds a bunch of lines at the end of the code to handle the small part they were asked to
develop.
xvii
Introduction
Many times, front-end developers don’t specialize in T-SQL, so do not usually have
a deep understanding of the SQL Server optimizer. Especially in the case of “let’s just
add lines of code to the bottom of this to handle additional functionality,” calls to the
database can increase exponentially; in many cases, calls grab the same data over and
over. And, oh, by now, over half the company is using this app in one way or another – or
perhaps three ways. The vast majority of these uses, by the way, were never intended by
anyone who had ever touched the code.
Users complain about slowness and performance. Even more frustrating, all of the
other business-critical applications that use the same database(s) become slower and
slower as they fight for resources and locks with the application and its chatty data calls.
Also, of course, every developer that has ever touched this application has moved on or
has been promoted and hasn’t looked at code for years, so has no recollection of ever
manipulating any code even remotely similar to this patched-together behemoth that is
rampaging through the company infrastructure.
Congratulations!
You have inherited one of these types of applications, or you probably wouldn’t be
here reading this book. Although there will be (possibly many) times that you may
want to cry, yell, or swear, this will also give you some unparalleled opportunities to be
a hero and pull off some very spectacular-seeming fixes. Just remember, though, that
when you really fix something amazing, most people will be completely oblivious to
that fact. Then, when you do something you think is so obvious that a worm out there
on the sidewalk could probably manage it, you may get so many congratulations and
thanks that you’ll wonder if you really did something magical. That is probably more
of a general life/job observation and not related specifically to legacy code, but it’s also
prevalent here.
xviii
Introduction
We are going to continue on from the point of “Okay, this has been identified as an
issue. Now what do I do with it?” Most of what we’ll be doing is actually looking at the
code with the help of a few performance measures and learning about best practices to
help identify problem areas. You should be familiar with basic T-SQL coding syntax and
techniques and how to do a bit more advanced querying.
We will cover most of the issues commonly seen by object type, as well as a couple
of less common problems just for fun. Once these problem areas within the object are
identified, you can then mitigate the performance issues with relatively low effort and
cost. Some objects may require a much deeper dive. Once we’ve done some triage to
help alleviate the immediate pain an object is causing, we will cover what is involved in
effectively performing the deeper dive.
We also will talk about how to quickly tell if you’re on the right track in terms of the
fixes you want to apply. We’ll go over some simple (and free) tools that can be used to
measure performance, so you can document the before/after metrics to go along with
the rest of the documentation you’re going to be sure to add so the next poor sod
(I mean the next person) who has to maintain this system will have an easier time of it!
xix
Another Random Scribd Document
with Unrelated Content
The Project Gutenberg eBook of Index of the
Project Gutenberg Works of Anthony Trollope
This ebook is for the use of anyone anywhere in the United States
and most other parts of the world at no cost and with almost no
restrictions whatsoever. You may copy it, give it away or re-use it
under the terms of the Project Gutenberg License included with this
ebook or online at www.gutenberg.org. If you are not located in the
United States, you will have to check the laws of the country where
you are located before using this eBook.
Language: English
ANTHONY TROLLOPE
## THE WARDEN
## HUNTING SKETCHES
## FRAMLEY PARSONAGE
## DOCTOR THORNE
## BARCHESTER TOWERS
## THE DUKE'S CHILDREN
## LA VENDEE
## CASTLE RICHMOND
## AN AUTOBIOGRAPHY
NINA BALATKA
## THE CLAVERINGS
## PHINEAS FINN
## PHINEAS REDUX
## THACKERAY
## ORLEY FARM
## MISS MACKENZIE
## COUSIN HENRY
## LINDA TRESSEL
## TRAVELLING SKETCHES
## LORD PALMERSTON
LA MERE BAUCHE
AARON TROW
RETURNING HOME
TABLES OF CONTENTS OF
VOLUMES
THE WARDEN
By Antony Trollope
CONTENTS
I. Hiram's Hospital
II. The Barchester Reformer
III. The Bishop of Barchester
IV. Hiram's Bedesmen
V. Dr Grantly Visits the Hospital
VI. The Warden's Tea Party
VII. The Jupiter
VIII. Plumstead Episcopi
IX. The Conference
X. Tribulation
XI. Iphigenia
XII. Mr Bold's Visit to Plumstead
XIII. The Warden's Decision
XIV. Mount Olympus
XV. Tom Towers, Dr Anticant, and Mr Sentiment
XVI. A Long Day in London
XVII. Sir Abraham Haphazard
XVIII. The Warden Is Very Obstinate
XIX. The Warden Resigns
XX. Farewell
XXI. Conclusion
HUNTING SKETCHES
by Anthony Trollope
CONTENTS
NORTH AMERICA
By Anthony Trollope
In Two Volumes
Vol. I
CONTENTS
I. INTRODUCTION.
II. NEWPORT—RHODE ISLAND.
III. MAINE, NEW HAMPSHIRE, AND VERMONT.
IV. LOWER CANADA.
V. UPPER CANADA.
VI. THE CONNEXION OF THE CANADAS
WITH GREAT BRITAIN.
VII. NIAGARA.
VIII. NORTH AND WEST.
IX. FROM NIAGARA TO THE MISSISSIPPI.
X. THE UPPER MISSISSIPPI.
XI. CERES AMERICANA.
XII. BUFFALO TO NEW YORK.
XIII. AN APOLOGY FOR THE WAR.
XIV. NEW YORK.
XV. THE CONSTITUTION OF THE
STATE OF NEW YORK.
XVI. BOSTON.
XVII. CAMBRIDGE AND LOWELL.
XVIII. THE RIGHTS OF WOMEN.
XIX. EDUCATION AND RELIGION.
XX. FROM BOSTON TO WASHINGTON.
NORTH AMERICA
By Anthony Trollope
In Two Volumes
Vol. II
CONTENTS
I. WASHINGTON.
II. CONGRESS.
III. THE CAUSES OF THE WAR.
IV. WASHINGTON TO ST. LOUIS.
V. MISSOURI.
VI. CAIRO AND CAMP WOOD.
VII. THE ARMY OF THE NORTH.
VIII. BACK TO BOSTON.
IX. THE CONSTITUTION OF
THE UNITED STATES.
X. THE GOVERNMENT.
XI. THE LAW COURTS AND LAWYERS
OF THE UNITED STATES.
XII. THE FINANCIAL POSITION.
XIII. THE POST-OFFICE.
XIV. AMERICAN HOTELS.
XV. LITERATURE.
XVI. CONCLUSION.
APPENDIX A. DECLARATION OF
INDEPENDENCE.
APPENDIX B. ARTICLES OF
CONFEDERATION, ETC.
APPENDIX C. CONSTITUTION OF
THE UNITED STATES.
CONTENTS
Volume I
I. Ferdinand Lopez
II. Everett Wharton
III. Mr. Abel Wharton, Q.C.
IV. Mrs. Roby
V. "No One Knows Anything About Him"
VI. An Old Friend Goes to Windsor
VII. Another Old Friend
VIII. The Beginning of a New Career
IX. Mrs. Dick's Dinner Party.—No. I
X. Mrs. Dick's Dinner Party.—No. II
XI. Carlton Terrace
XII. The Gathering of Clouds
XIII. Mr. Wharton Complains
XIV. A Lover's Perseverance
XV. Arthur Fletcher
XVI. Never Run Away!
XVII. Good-Bye
XVIII. The Duke of Omnium Thinks of Himself
XIX. Vulgarity
XX. Sir Orlando's Policy
XXI. The Duchess's New Swan
XXII. St. James's Park
XXIII. Surrender
XXIV. The Marriage
XXV. The Beginning of the Honeymoon
XXVI. The End of the Honeymoon
XXVII. The Duke's Misery
XXVIII. The Duchess Is Much Troubled
XXIX. The Two Candidates for Silverbridge
XXX. "Yes;—a Lie!"
XXXI. "Yes;—with a Horsewhip in My Hand"
XXXII. "What Business Is It of Yours?"
XXXIII. Showing That a Man Should Not Howl
XXXIV. The Silverbridge Election
XXXV. Lopez Back in London
XXXVI. The Jolly Blackbird
XXXVII. The Horns
XXXVIII. Sir Orlando Retires
XXXIX. "Get Round Him"
XL. "Come and Try It"
Volume II
FRAMLEY PARSONAGE
By Anthony Trollope
CONTENTS
CONTENTS