Guest User

Untitled

a guest
Jan 19th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. SELECT TOP 100 u.DisplayName
  2. FROM dbo.Users AS u
  3. INNER HASH JOIN dbo.Posts AS p
  4. ON p.OwnerUserId = u.Id
  5. ORDER BY p.Id;
  6.  
  7. EXEC sp_create_plan_guide
  8. @name = N'brimful of hash joins',
  9. @stmt = N'SELECT TOP 100 u.DisplayName
  10. FROM dbo.Users AS u
  11. INNER HASH JOIN dbo.Posts AS p
  12. ON p.OwnerUserId = u.Id
  13. ORDER BY p.Id;',
  14. @type = N'SQL',
  15. @module_or_batch = NULL,
  16. @params = NULL,
  17. @hints = N'OPTION(MAX_GRANT_PERCENT = 0)'
  18. GO
  19.  
  20. No Guide:
  21. Table 'Users'. Scan count 7, logical reads 113953,
  22. Table 'Posts'. Scan count 7, logical reads 9777604,
  23. Table 'Workfile'. Scan count 0, logical reads 0,
  24. Table 'Worktable'. Scan count 0, logical reads 0,
  25.  
  26. SQL Server Execution Times:
  27. CPU time = 40001 ms, elapsed time = 6992 ms.
  28.  
  29. Guided By Voices:
  30. Table 'Users'. Scan count 7, logical reads 113953,
  31. Table 'Posts'. Scan count 7, logical reads 9776298,
  32. Table 'Workfile'. Scan count 3312, logical reads 362880, physical reads 56144, read-ahead reads 446000,
  33. Table 'Worktable'. Scan count 0, logical reads 0,
  34.  
  35.  
  36. SQL Server Execution Times:
  37. CPU time = 66593 ms, elapsed time = 34270 ms.
  38.  
  39. @hints = N'OPTION(LOOP JOIN, MERGE JOIN, TABLE HINT(p, FORCESEEK))'
  40.  
  41. Msg 1042, Level 16, State 1, Line 64
  42. Conflicting JOIN optimizer hints specified.
  43.  
  44. Msg 10516, Level 16, State 1, Procedure sp_create_plan_guide, Line 20 [Batch Start Line 59]
  45. Cannot create plan guide 'brimful of hash joins' because @module_or_batch can not be compiled.
Add Comment
Please, Sign In to add comment