Rules

edited December 5, 2017 4:00PM in SQL Prompt
Hi Red Gate Team,

I like the idea of code analysis rules and I know that I can decide to disable them if I like. Nevertheless I would not enable some of the rules by default.
For example:

ST011 Reason: Table variables do not provide statistics by default (you can enable by DBCC command but this is not a well known feature). Table variables are the better choice if you allocate one page only but otherwise consider to use temporary tables instead.

EI028 Resaon: I think you cannot always set a default for NOT NULL columns for several reasons.

PE008 : Reason: NOCOUNT is OFF per default, you do not even have to set it off.

PB009 : Reason : What is the reason for 1 or 2 bytes only?

PE027 : Reason: There are definitly situations you would recompile a procedure before each exection.

Additionally I perfer do avaiod abbreviations like the var and const in MI001, P017

It would be nice to get the rule identifier in the tool tip like P017 : ... to find the appropriate rule in the code rule overview in order to disable the rule on demand or even forever.

Thanks for your support!

Torsten

Answers

  • I'm not sure I can answer them all, but PB009 makes sense for 1 byte. You actually hurt yourself storing 1byte in a varchar field. That should be CHAR. It's equally slightly silly for a VARCHAR(2), but not as outright wrong.

    On PE027, this is likely to occur, but much more likely is to focus on recompile on the statement level, that's why that recommendation.

    I like the suggestion on disabling rules forever, because there are a few I'd disable as you do.
  • edited December 11, 2017 11:02AM
    Hi Grant,

    thanks for reply.
    " You actually hurt yourself storing 1byte in a varchar field. That should be CHAR. It's equally slightly silly for a VARCHAR(2), but not as outright wrong"

    I just asked why it is limited to 2 bytes:
    I hope I calculated correctly ...

    Should be 10 bytes:
    9yepveize91n.png
  • Or 6 actually because it's the VARCHAR side that hurts. I hadn't actually done the calculations like that before. I figured after 2 who cares. 6 ought to be the limit.

  • edited December 11, 2017 11:40AM
    Hi Grant!

    Should be 10 cause you should use varchar if the length differs from 0(1) to 10. So in average you should see 5Bytes in varchar. That is the break even.
    You have to look from the varchar perspective.
Sign In or Register to comment.