Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT TOP 100 u.DisplayName
- FROM dbo.Users AS u
- INNER HASH JOIN dbo.Posts AS p
- ON p.OwnerUserId = u.Id
- ORDER BY p.Id;
- EXEC sp_create_plan_guide
- @name = N'brimful of hash joins',
- @stmt = N'SELECT TOP 100 u.DisplayName
- FROM dbo.Users AS u
- INNER HASH JOIN dbo.Posts AS p
- ON p.OwnerUserId = u.Id
- ORDER BY p.Id;',
- @type = N'SQL',
- @module_or_batch = NULL,
- @params = NULL,
- @hints = N'OPTION(MAX_GRANT_PERCENT = 0)'
- GO
- No Guide:
- Table 'Users'. Scan count 7, logical reads 113953,
- Table 'Posts'. Scan count 7, logical reads 9777604,
- Table 'Workfile'. Scan count 0, logical reads 0,
- Table 'Worktable'. Scan count 0, logical reads 0,
- SQL Server Execution Times:
- CPU time = 40001 ms, elapsed time = 6992 ms.
- Guided By Voices:
- Table 'Users'. Scan count 7, logical reads 113953,
- Table 'Posts'. Scan count 7, logical reads 9776298,
- Table 'Workfile'. Scan count 3312, logical reads 362880, physical reads 56144, read-ahead reads 446000,
- Table 'Worktable'. Scan count 0, logical reads 0,
- SQL Server Execution Times:
- CPU time = 66593 ms, elapsed time = 34270 ms.
- @hints = N'OPTION(LOOP JOIN, MERGE JOIN, TABLE HINT(p, FORCESEEK))'
- Msg 1042, Level 16, State 1, Line 64
- Conflicting JOIN optimizer hints specified.
- Msg 10516, Level 16, State 1, Procedure sp_create_plan_guide, Line 20 [Batch Start Line 59]
- Cannot create plan guide 'brimful of hash joins' because @module_or_batch can not be compiled.
Add Comment
Please, Sign In to add comment