Click here to Skip to main content
15,910,083 members
Home / Discussions / Database
   

Database

 
GeneralLooking for good ADO book suggestion Pin
Flack21-Dec-03 14:15
Flack21-Dec-03 14:15 
GeneralRe: Looking for good ADO book suggestion Pin
Colin Angus Mackay21-Dec-03 14:50
Colin Angus Mackay21-Dec-03 14:50 
GeneralMicrosoft SQL Server - Bulk Update Lock Pin
CillyMe19-Dec-03 21:36
CillyMe19-Dec-03 21:36 
QuestionWhat's the best Desktop Database for Windows Forms Apps? Pin
bJoeyLouie19-Dec-03 8:51
bJoeyLouie19-Dec-03 8:51 
AnswerRe: What's the best Desktop Database for Windows Forms Apps? Pin
SimonS26-Dec-03 21:19
SimonS26-Dec-03 21:19 
GeneralRe: What's the best Desktop Database for Windows Forms Apps? Pin
Mike Dimmick5-Jan-04 5:50
Mike Dimmick5-Jan-04 5:50 
GeneralRe: What's the best Desktop Database for Windows Forms Apps? Pin
DaveMcL5-Jan-04 14:02
DaveMcL5-Jan-04 14:02 
GeneralQuery Optimization - MCAD question. Pin
CillyMe18-Dec-03 4:09
CillyMe18-Dec-03 4:09 
Here's a MCAD question.. See if any of you wizards can help me get thru this:

You need to tune the following query:

SELECT P.PolicyNumber, P.IssueState, AP.Agent FROM Policy AS P
JOIN AgentPolicy AS AP
ON (P.PolicyNumber = AP.PolicyNumber)
WHERE IssueState='NY'
AND PolicyDate BETWEEN '2/1/2001' AND '3/4/2002'
AND FaceAmount > 10000

They also presented to you the "Show Execution Plan" from Query Analyzer:
Cluster Index Scan - 95% cost --> This tell me that the index scan is the blood sucker - ie. Should work on index --> This points to option (d) and (e)

The objective is to tune the query. You have the following options:
a. Rewrite the query to eliminate BETWEEN keyword and rewrite the query without it (Okay, this is wrong answer, i guess no one have trouble with this.)
b. Add a HASH join hint
(Reference: http://www.sql-server-performance.com/hints_join.asp)
c. Add a WITH(INDEX(0)) table hint to "Policy" table (QUESTION 3: How do you do a index hint by the way??)
d. Update Statistics on "Policy" table.
e. Execute DBCC DBREINDEX on "Policy" table.

Choose one.

My shot at it would be to eliminate (a), (b) and (c) because of my faith in "Query Optimizer" that it will do a better job than me. Now, (d) and (e) can be equally correct.And I can't pick one over the other. The model answer is (d) - but it doesn't tell you why (e) is eliminated. The question itself didn't state whether the index is fragmented, but neither did it state that the statistics is up-to-date.

QUESTION 2: In addition to the question itself, is there any example in which we need to "hint" whether the query should be executed using HASH/MERGE or LOOP join? Doesn't the query optimizer do this for you and that Query Optimizer does a better job?

QUESTION 3: For option (c), their explanation for rejecting the option is as follows:
"The estimated execution plan shows that a clustered index scan is going to be used, not a seek. It'd be better if the query used an inedx seek instead. We can try to force an index seek with a table hint. However, we shold use the hint inedx(1), not the hint index(0)" -- What??? How do we write an index hint in a SQL query? Anyway, i thought this option should be eliminated because normally we rely on Query Optimizer and not to hardcode query hints.

Thanks in advance.
GeneralRe: Query Optimization - MCAD question. Pin
Jeff Varszegi18-Dec-03 14:49
professionalJeff Varszegi18-Dec-03 14:49 
GeneralRe: Query Optimization - MCAD question. Pin
CillyMe18-Dec-03 16:00
CillyMe18-Dec-03 16:00 
GeneralRe: Query Optimization - MCAD question. Pin
Jeff Varszegi18-Dec-03 17:00
professionalJeff Varszegi18-Dec-03 17:00 
GeneralRe: Query Optimization - MCAD question. Pin
CillyMe18-Dec-03 22:04
CillyMe18-Dec-03 22:04 
GeneralRe: Query Optimization - MCAD question. Pin
Jeff Varszegi19-Dec-03 6:12
professionalJeff Varszegi19-Dec-03 6:12 
GeneralRe: Query Optimization - MCAD question. Pin
Jeff Varszegi19-Dec-03 6:17
professionalJeff Varszegi19-Dec-03 6:17 
GeneralRe: Query Optimization - MCAD question. Pin
CillyMe19-Dec-03 15:42
CillyMe19-Dec-03 15:42 
GeneralRe: Query Optimization - MCAD question. Pin
Mike Dimmick5-Jan-04 6:20
Mike Dimmick5-Jan-04 6:20 
GeneralSqlException in ADO.NET Pin
Y. Liu18-Dec-03 4:02
Y. Liu18-Dec-03 4:02 
GeneralRe: SqlException in ADO.NET Pin
Jeff Varszegi18-Dec-03 14:50
professionalJeff Varszegi18-Dec-03 14:50 
GeneralRe: SqlException in ADO.NET Pin
Y. Liu19-Dec-03 4:36
Y. Liu19-Dec-03 4:36 
GeneralRe: SqlException in ADO.NET Pin
Jeff Varszegi19-Dec-03 5:43
professionalJeff Varszegi19-Dec-03 5:43 
GeneralRe: SqlException in ADO.NET Pin
SimonS24-Dec-03 8:31
SimonS24-Dec-03 8:31 
GeneralDataSet Pin
Large Data File17-Dec-03 20:40
Large Data File17-Dec-03 20:40 
GeneralRe: DataSet Pin
Not Active18-Dec-03 2:53
mentorNot Active18-Dec-03 2:53 
GeneralSql question Pin
pankajdaga17-Dec-03 7:18
pankajdaga17-Dec-03 7:18 
GeneralRe: Sql question Pin
Not Active17-Dec-03 8:22
mentorNot Active17-Dec-03 8:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.