Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 what is table_hint, .....

Author  Topic 

abc
Starting Member

48 Posts

Posted - 2001-12-11 : 03:04:08
When read Book online, I try to understand the meaning of query hint, table hint, index hint, join hint.... And I really don't understand these's meaning. Tell me more about them pls

Thanks for your attention

mfemenel
Professor Frink

1421 Posts

Posted - 2001-12-11 : 08:13:52
a hint is basically a way of telling sql server, "hey, instead of figuring it out on your own, do it this way". For example, SQL might create an execution plan for your query that you don't agree with. You can override it's choices by giving it hints as to how you would prefer it to behave. Generally, it's reccomended that you let SQL "do it's business" without your intervention. I would only reccomend you use hints if you're sure of what you're doing.

Mike
"A program is a device used to convert data into error messages."
Go to Top of Page

JustinBigelow
SQL Gigolo

1157 Posts

Posted - 2001-12-11 : 10:18:17
quote:

I would only reccomend you use hints if you're sure of what you're doing.



I never get to use hints

Justin

Go to Top of Page

abc
Starting Member

48 Posts

Posted - 2001-12-12 : 01:53:02
Thanks for mfemene guide, could you give me an example to illutrate the different between use not use or not use table hint, query hint...

Thanks for your attention
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2001-12-12 : 07:50:30
hints were common in v6.5 - not so necessary in v7+ as the optimiser tends to be more reliable - still makes some glaring errors though.

common hints are index, nolock and tablockx, holdlock

select * from tbl with (index=ix1, nolock)

the index tells the optimiser to use this index (it may just use the index to scan if it's not useful.
the nolock tells it not to take or honour locks - this is used to check what's happenning on a production system with deadlocking or slowing down the processing (much) or checking what is happenning within a transaction. Beware of using it in production code as it can produce strange results.
Use tablockx, holdlock to exclusively lock a table for the duration of a transaction (don't forget the holldlock).

option ...
query hints restrict what type of plan is available to the optimiser
MAXDOP is used to overcome bugs and fast is also possibly useful - I've suggested it to people but never heard about the outcome.


==========================================
Cursors are useful if you don't know sql.
Beer is not cold and it isn't fizzy.

Edited by - nr on 12/12/2001 07:55:10
Go to Top of Page

Doug G
Constraint Violating Yak Guru

331 Posts

Posted - 2001-12-12 : 19:36:38
quote:
quote:
--------------------------------------------------------------------------------

I would only reccomend you use hints if you're sure of what you're doing.

--------------------------------------------------------------------------------


I never get to use hints

Justin




======
Doug G
======
Go to Top of Page
   

- Advertisement -