The Most Common Query Blunders...

  • Grant Fritchey (12/28/2015)


    I have two presentations I do on best practices. Both slide decks are available on slideshare.net. That could act as a guide. Just give me some attribution if you use 'em.

    That's an incredibly generous offer! Thank you! And yes, I would make sure that you were given full acknowledgement.

    Any chance yo could provide the specific links? I was able to find your name in the user directory and was surprised by the amount of material returned when searching for "SQL Server Best Practices". I just want to be sure I'm looking at the correct decks.

    Jeff Moden (12/28/2015)


    Grant Fritchey (12/28/2015)


    I have two presentations I do on best practices. Both slide decks are available on slideshare.net. That could act as a guide. Just give me some attribution if you use 'em.

    Very cool of you to make such an offer, Grant.

    That's an understatement... Between Grant's offer, Kevin's offer and the suggestions of others... I'm blown away. This really is an amazing community!

  • Eric M Russell (12/28/2015)


    In addition to what's already been mentioned above:

    On the fly data type conversion and transformations, both explicit and implicit

    Distributed queries (ie: joining tables between multiple instances via linked server connections)

    Needless ORDER BY clause within views, sub-queries, and resultsets

    Needless use of (NOLOCK) or (TABLOCK)

    Use of generic stored procedures with overloaded functionality

    Needless use of dymanic SQL within stored procedures

    +1

    😎

  • Jason A. Long (12/28/2015)


    Grant Fritchey (12/28/2015)


    I have two presentations I do on best practices. Both slide decks are available on slideshare.net. That could act as a guide. Just give me some attribution if you use 'em.

    That's an incredibly generous offer! Thank you! And yes, I would make sure that you were given full acknowledgement.

    Any chance yo could provide the specific links? I was able to find your name in the user directory and was surprised by the amount of material returned when searching for "SQL Server Best Practices". I just want to be sure I'm looking at the correct decks.

    Jeff Moden (12/28/2015)


    Grant Fritchey (12/28/2015)


    I have two presentations I do on best practices. Both slide decks are available on slideshare.net. That could act as a guide. Just give me some attribution if you use 'em.

    Very cool of you to make such an offer, Grant.

    That's an understatement... Between Grant's offer, Kevin's offer and the suggestions of others... I'm blown away. This really is an amazing community!

    Yes it is. Personally, I think it's the best SQL Server forum in the world.

    You certainly have a lot to think about. 😉

  • Jeff Moden (12/28/2015)


    Grant Fritchey (12/28/2015)


    I have two presentations I do on best practices. Both slide decks are available on slideshare.net. That could act as a guide. Just give me some attribution if you use 'em.

    Very cool of you to make such an offer, Grant.

    Not really. The stuff is out there. Better to just offer it up. Plus, it's just the slides. No sample code, no additional insight or documentation. Again, not like I'm really offering that much, but they're welcome to it.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Jason A. Long (12/28/2015)


    Grant Fritchey (12/28/2015)


    I have two presentations I do on best practices. Both slide decks are available on slideshare.net. That could act as a guide. Just give me some attribution if you use 'em.

    That's an incredibly generous offer! Thank you! And yes, I would make sure that you were given full acknowledgement.

    Any chance yo could provide the specific links? I was able to find your name in the user directory and was surprised by the amount of material returned when searching for "SQL Server Best Practices". I just want to be sure I'm looking at the correct decks.

    Jeff Moden (12/28/2015)


    Grant Fritchey (12/28/2015)


    I have two presentations I do on best practices. Both slide decks are available on slideshare.net. That could act as a guide. Just give me some attribution if you use 'em.

    Very cool of you to make such an offer, Grant.

    Three slides worth here. The other one doesn't seem to be up there. I'll go upload it.

    That's an understatement... Between Grant's offer, Kevin's offer and the suggestions of others... I'm blown away. This really is an amazing community!

    Weird. Editing this because it doesn't have my post.

    Wild.

    Here's the first slide deck. There are only three slides on T-SQL.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Jason A. Long (12/28/2015)


    Grant Fritchey (12/28/2015)


    I have two presentations I do on best practices. Both slide decks are available on slideshare.net. That could act as a guide. Just give me some attribution if you use 'em.

    That's an incredibly generous offer! Thank you! And yes, I would make sure that you were given full acknowledgement.

    Any chance yo could provide the specific links? I was able to find your name in the user directory and was surprised by the amount of material returned when searching for "SQL Server Best Practices". I just want to be sure I'm looking at the correct decks.

    Jeff Moden (12/28/2015)


    Grant Fritchey (12/28/2015)


    I have two presentations I do on best practices. Both slide decks are available on slideshare.net. That could act as a guide. Just give me some attribution if you use 'em.

    Very cool of you to make such an offer, Grant.

    That's an understatement... Between Grant's offer, Kevin's offer and the suggestions of others... I'm blown away. This really is an amazing community!

    Here's the other one. It's somewhat repetitive. You'll notice that I don't list 'SELECT *' as a problem. As Jeff points out, it might not be. Not to say it won't be or can't be, but it's not an automatic issue unlike, say, multi-statement table valued user defined functions.

    By the way, speaking of attribution, every single time I talk about cursors and WHILE loops, I use rbar (rebar) as a term and give Jeff full attribution. It's not on the slides (might be something I should fix).

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Grant Fritchey (12/28/2015)


    Jeff Moden (12/28/2015)


    Grant Fritchey (12/28/2015)


    I have two presentations I do on best practices. Both slide decks are available on slideshare.net. That could act as a guide. Just give me some attribution if you use 'em.

    Very cool of you to make such an offer, Grant.

    Not really. The stuff is out there. Better to just offer it up. Plus, it's just the slides. No sample code, no additional insight or documentation. Again, not like I'm really offering that much, but they're welcome to it.

    Understood but my comment was because not many people will put stuff out on slideshare to begin with and you pointing it out and telling folks they could use it (with attribution, of course) was frosting on the cake. I always knew it but you continue to prove what a great person you are. Thanks, Grant.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Ooh, another thing I will chime in with. Some of the WORST things I see done on SQL Server have nothing to do with the databases/applications they run - it is the DEFAULT SETTINGs that come with clicking Next-Next-Next throughout the infrastructure that SQL Server runs on!! That's another session I can do for you - SQL Server Defaults SUCK!!. Definitely a Top 5 fav of my collection of sessions. 😎

    Best,
    Kevin G. Boles
    SQL Server Consultant
    SQL MVP 2007-2012
    TheSQLGuru on googles mail service

  • Jeff Moden (12/28/2015)


    Grant Fritchey (12/28/2015)


    Jeff Moden (12/28/2015)


    Grant Fritchey (12/28/2015)


    I have two presentations I do on best practices. Both slide decks are available on slideshare.net. That could act as a guide. Just give me some attribution if you use 'em.

    Very cool of you to make such an offer, Grant.

    Not really. The stuff is out there. Better to just offer it up. Plus, it's just the slides. No sample code, no additional insight or documentation. Again, not like I'm really offering that much, but they're welcome to it.

    Understood but my comment was because not many people will put stuff out on slideshare to begin with and you pointing it out and telling folks they could use it (with attribution, of course) was frosting on the cake. I always knew it but you continue to prove what a great person you are. Thanks, Grant.

    You're making me blush here.

    Thanks.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • TheSQLGuru (12/28/2015)


    Ooh, another thing I will chime in with. Some of the WORST things I see done on SQL Server have nothing to do with the databases/applications they run - it is the DEFAULT SETTINGs that come with clicking Next-Next-Next throughout the infrastructure that SQL Server runs on!! That's another session I can do for you - SQL Server Defaults SUCK!!. Definitely a Top 5 fav of my collection of sessions. 😎

    My apologies, Kevin. I also meant to tip my hat to you, as well. You've offered an extremely good thing. I love this community! You guys are great!

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • TheSQLGuru (12/28/2015)


    Ooh, another thing I will chime in with. Some of the WORST things I see done on SQL Server have nothing to do with the databases/applications they run - it is the DEFAULT SETTINGs that come with clicking Next-Next-Next throughout the infrastructure that SQL Server runs on!! That's another session I can do for you - SQL Server Defaults SUCK!!. Definitely a Top 5 fav of my collection of sessions. 😎

    Do you mean like letting all the data and log files default under "C:\Program Files\Microsoft SQL Server" ?

    "Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho

  • Eric M Russell (12/28/2015)


    TheSQLGuru (12/28/2015)


    Ooh, another thing I will chime in with. Some of the WORST things I see done on SQL Server have nothing to do with the databases/applications they run - it is the DEFAULT SETTINGs that come with clicking Next-Next-Next throughout the infrastructure that SQL Server runs on!! That's another session I can do for you - SQL Server Defaults SUCK!!. Definitely a Top 5 fav of my collection of sessions. 😎

    Do you mean like letting all the data and log files default under "C:\Program Files\Microsoft SQL Server" ?

    Or not setting correctly the:

    - Maximum degree of parallelism

    - Cost threshold for parallelism

    - Min and Max memory

    Among others.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Luis Cazares (12/28/2015)


    Eric M Russell (12/28/2015)


    TheSQLGuru (12/28/2015)


    Ooh, another thing I will chime in with. Some of the WORST things I see done on SQL Server have nothing to do with the databases/applications they run - it is the DEFAULT SETTINGs that come with clicking Next-Next-Next throughout the infrastructure that SQL Server runs on!! That's another session I can do for you - SQL Server Defaults SUCK!!. Definitely a Top 5 fav of my collection of sessions. 😎

    Do you mean like letting all the data and log files default under "C:\Program Files\Microsoft SQL Server" ?

    Or not setting correctly the:

    - Maximum degree of parallelism

    - Cost threshold for parallelism

    - Min and Max memory

    Among others.

    LOTS AND LOTS of bad defaults!! 1MB data file growth is a fav, even if you are on SSDs. But don't limit yourself to just SQL Server install!! Balance Power anyone?? NFTS cluster size on format? Virtualization system defaults, IO stack defaults, etc., etc. Next-Next-Next is just HORRIBLE - EVERYWHERE!! 😎

    Best,
    Kevin G. Boles
    SQL Server Consultant
    SQL MVP 2007-2012
    TheSQLGuru on googles mail service

  • Luis Cazares (12/28/2015)


    Eric M Russell (12/28/2015)


    TheSQLGuru (12/28/2015)


    Ooh, another thing I will chime in with. Some of the WORST things I see done on SQL Server have nothing to do with the databases/applications they run - it is the DEFAULT SETTINGs that come with clicking Next-Next-Next throughout the infrastructure that SQL Server runs on!! That's another session I can do for you - SQL Server Defaults SUCK!!. Definitely a Top 5 fav of my collection of sessions. 😎

    Do you mean like letting all the data and log files default under "C:\Program Files\Microsoft SQL Server" ?

    Or not setting correctly the:

    - Maximum degree of parallelism

    - Cost threshold for parallelism

    - Min and Max memory

    Among others.

    What's appropriate for the above depends on the use case of the database server: OLTP, data warehouse, dedicated or shared with other aps, etc.

    "Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho

  • The most common/easiest to fix mistakes:

    Someone beat me to it but NOLOCK table hints are the #1 mistake I have seen. I would go so far as to say it's become an epidemic in the industry. Real DBAs know better but a majority of "DBA"s think that throwing NOLOCK hints everywhere is a best practice.

    Not enough I/O: tempdb, mdfs, ndfs, ldfs, OS, SQL Install spread across too few disks.

    databases set to full recovery in places where transaction log backups are not happening. Common in many dev environments.

    Nullable columns that always contain data (or where a blank or -1 would do).

    No index on Foreign keys.

    RBAR and hidden RBAR (not always as simple to fix/replace as what I've already mentioned but it's falls in the category of "most common query blunders". )

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

Viewing 15 posts - 31 through 45 (of 74 total)

You must be logged in to reply to this topic. Login to reply