Book Review: Learn T-SQL Querying by Pedro Lopes and Pam Lahoud

Book Reviews
Learn T-SQL Querying by Lopes and Lahoud
Learn T-SQL Querying by Lopes and Lahoud

You’ve been writing queries for at least a year or two, and you’re curious about what’s happening under the hood when SQL Server runs a query. You want to know what you can do to improve your queries, tune your indexes, and change SQL Server’s configuration settings so that your results will return faster.

The book Learn T-SQL Querying is for curious people like you.

When I first read the Table of Contents, I wondered how the authors were going to cover so much ground in ~450 pages – and they did a great job striking a balance between giving you enough to get started, versus dragging you into the weeds with obscure internals details. Great example: pages 170-171 only spend two paragraphs on why you shouldn’t be using cursors – nuff said. There were so many times where I read one paragraph and thought, “I sure hope the readers get how important this is.” It’s a lot of killer, and not a lot of filler.

Pam & Pedro give you enough to pique your curiosity and make your queries go faster, and if you’re interested in learning more about a specific thing, well, that’s what Google is for. This book teaches you enough to Google for the right things.

Despite the title, it is by no means a level 100, here’s-how-to-write-a-query book. The first couple dozen pages act as if they’re a gentle on-ramp to the parts of a query, but just jump past those to chapter 2, understanding query processing, and Pedro Lopes (@SQLPedro) and Pam Lahoud (@SQLGoddess) start getting into how a query is optimized.

Or if you’re not quite so curious, and you just want faster queries, jump to chapter 6 and learn about anti-patterns.

Or if you’re not sure what queries you should review first, and you’re curious about what it would take to build your own plan cache analysis tool, turn to page 268 and start reading about the plan cache DMVs.

I realized the picture should have two thumbs up, not one

That is really my only small objection to the book, and it’s a tiny one: it seems just a little bit out of order, with some really challenging concepts coming before the easier parts about simple things you can do to make your queries go faster. (Page 17 introduces the WHERE clause as if you’ve never heard of it before, and by page 30, we’re into worker threads, tasks, and degrees of parallelism.)

That’s easy to work around, however: just hit the Table of Contents, find the parts that interest you, and read those first. You’ll come back to the others later anyway because this is the kind of book that rewards repeated reading. More than that, it also rewards using the contents as a jumping-off point for additional learning.

I highly, highly recommend this book for folks who want to start a curious journey into SQL Server execution and tuning. Get it, and let me know what you think.

Previous Post
Developers: Azure SQL DB Serverless can save you money.
Next Post
I’m coming to SQL Saturday Salt Lake City in August!

15 Comments. Leave new

  • Kerry Patrick
    May 8, 2019 7:40 am

    How SQL version-specific is the information about query optimization? Would this book be just as applicable to someone writing queries against SQL Server 2012 as SQL Server 2017 or Azure SQL?

    • Oh that’s a great question! They cover differences in SQL Server 2017 and 2019 – for example, when explaining why some kinds of user-defined functions are slow, they talk about how it improves in 2017 and 2019. I’d still recommend it for folks using 2012 & newer. (Probably not for 2008/2008R2 though.)

  • Geo Hernandez
    May 8, 2019 8:08 am

    Interesting review, I have attended a session of @PedroLopes in the past and was a good surprise to know that recently he had written a book, I suppose that with this number of pages the challenge is how to compact the vast knowledge about T-SQL in a friendly way.

  • Wise Old Man
    May 8, 2019 9:14 am

    Here’s an off-the-wall comment about the book appearing on Amazon through the link. When I look at the photos of the authors, Pedro is in his polo shirt and looks like someone who would be writing a book about SQL Server. Pam however has a photo with her son, which makes it look like she’d be writing children’s books instead. It’s no knock against her, and I’m sure she chose that photo, but it’s strange how we tend to define women by their children and not their accomplishments. Kudos to both for writing a book that touches on a great subject.

    • My question to you sir would be, why do you assume a woman posing with her son would be writing children’s books and not deep technical books? #flipthescript

      • Totally agree with you Pam. Clearly Pedro needs to change this photo to include a child. Then maybe he’d look more accomplished. Children and accomplishment are not mutually exclusive. This is like a Rorschach Test. “Oh, you see a children’s writer and lack of accomplishment there? Interesting…”

        • I also feel compelled to say that children’s book writers are certainly just as accomplished as technical writers, but the assumption that a woman who has a child doesn’t do or know anything else is what I’m going after. I’m sure most people don’t consciously think that (or at least wouldn’t admit it in public), but the more associations like this we can make, the more that subconscious bias gets challenged. Thus I will keep my profile picture, and I’ll see if Pedro wants to add a photo with his kids 🙂

      • Christopher
        May 8, 2019 11:57 am

        That is a great answer, Pam. We all need to re-evaluate our perspectives from time to time.

        • If I ever write a book, I’m going to have a cover photo of me with my 9 grandkids climbing all over me. Wonder what that will say?

    • To quote taco kid “Por que no las dos?” (Why not both?)

  • Thanks for the review Brent! I’m really glad you enjoyed the book! I agree about the zero to advanced in one chapter, and the order. A lot of that comes from being locked into the outline before we actually wrote the book. If we get to do a revision, we would likely look at moving things around a bit.

  • Is there a level 100 “How to write a query” book you can recommend in tandem with this one?


Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.