Query Hints

  • Comments posted to this topic are about the item Query Hints

  • Personally I would say all four answers are correct because you have the FORCEPLAN option which essentially is a query optimizer hint.

    Even BOL talks about a query optimizer hint.

    http://msdn.microsoft.com/en-us/library/ms188344.aspx

    [font="Verdana"]Markus Bohse[/font]

  • Not having that much experience as a developer and even less as a DBA I have followed the recommendation

    Because the SQL Server query optimizer typically selects the best execution plan for a query, we recommend that hints be used only as a last resort by experienced developers and database administrators

    and leave using hints to those better trained and more knowledgeable

    Yet when reading this:

    OPTIMIZE FOR ( @variable_name { UNKNOWN | = literal_constant } [ , ...n ] )

    Instructs the query optimizer to use a particular value for a local variable when the query is compiled and optimized. The value is used only during query optimization, and not during query execution.

    From:

    http://msdn.microsoft.com/en-us/library/ms181714.aspx

    All of which now leaves me further confused. Can anyone explain when an instruction is not a hint? ? ?

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • I was misled by the way BOL is laid out. It would appear from BOL that there are 3 type of Hints, Join Hints, Query Hints and Table Hints. When you select Query Hints it states there are 2, Query Hints and Table Hints, as if a join hint was a hint but not a query hint. I am not sure why it is structured the way it is.

  • Arguably not the best question or answer. Hints are an area that I think SQL is a little immature in how to describe/explain them. Please feel free to post suggestions in the BOL area if you think it's confusing and MS will review them. The more people that do that, the more likely they are to change/reword things

  • Thanks Steve. Actually I am inclined to agree with Markus and would have selected all four had I not consulted BOL.

  • MarkusB (12/15/2008)


    Personally I would say all four answers are correct because you have the FORCEPLAN option which essentially is a query optimizer hint.

    Even BOL talks about a query optimizer hint.

    http://msdn.microsoft.com/en-us/library/ms188344.aspx

    Yup... from there I see the following line.

    Query optimizer hints can also be used in queries to affect how SQL Server processes the SELECT statement.

    Poor copy editting in books online?



    --Mark Tassin
    MCITP - SQL Server DBA
    Proud member of the Anti-RBAR alliance.
    For help with Performance click this link[/url]
    For tips on how to post your problems[/url]

  • Cliff Jones (12/15/2008)


    Thanks Steve. Actually I am inclined to agree with Markus and would have selected all four had I not consulted BOL.

    Depends on what part of it you consult as well... One section doesn't mention them, another does.



    --Mark Tassin
    MCITP - SQL Server DBA
    Proud member of the Anti-RBAR alliance.
    For help with Performance click this link[/url]
    For tips on how to post your problems[/url]

  • I'd also like to point out that the link to BOL has this... which means there may be more than just the four...

    The following hints are described in this section:

    That doesn't mean that those are the only hints in existance, just that the following hints are in that section. As provided in the link above... there are optmizer hints as well.



    --Mark Tassin
    MCITP - SQL Server DBA
    Proud member of the Anti-RBAR alliance.
    For help with Performance click this link[/url]
    For tips on how to post your problems[/url]

  • My guess is that SET FORCEPLAN on is a setting, but likely people writing Books Online are having trouble coordinating things with the product so large.

    I'll award points back and edit the 4th answer to be something else.

  • Steve Jones - Editor (12/15/2008)


    My guess is that SET FORCEPLAN on is a setting, but likely people writing Books Online are having trouble coordinating things with the product so large.

    I'll award points back and edit the 4th answer to be something else.

    I agree that it's better to call SET FORCEPLAN a setting. But the actual plan you force the optimizer to use seems like a hint to me.

    Anyway thanks for awarding the point and changing the 4th answer.

    Hmmm, messaging hints, what could that be????:hehe::hehe::hehe:

    [font="Verdana"]Markus Bohse[/font]

  • Steve Jones - Editor (12/15/2008)


    My guess is that SET FORCEPLAN on is a setting, but likely people writing Books Online are having trouble coordinating things with the product so large.

    I'll award points back and edit the 4th answer to be something else.

    Great ...

  • Having submitted and had published 7 QODs myself I can only say to those of us (myself included) who rant about how misleading a question can be, l It is NOT easy. Remember Steve does most of the QODs, amongst all his other duties.

    So I offer this challenge to you: WRITE AND SUBMIT A QUESTION OF THE DAY Frame it / word it so that there is not a single rant claiming the answer(s) false / misleading or otherwise tainted. Remeber the questions should not be trivial, rather their main purpose is to teach us all about some aspect of SQL Server.

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • Thanks, bitbucket. It is hard, and it's really hard when "making up" answers to not collide with something in BOL. I was sure that calling something an "optimizer hint" was fiction since it wasn't listed.

    Oh well,

  • I don't think this one ranked very high on the rant scale. We didn't even fill up 2 complete pages yet.

Viewing 15 posts - 1 through 15 (of 28 total)

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