Click here to Skip to main content
15,921,169 members
Home / Discussions / Database
   

Database

 
AnswerRe: Is ADO thread safe ? Pin
Mike Dimmick18-Aug-04 3:03
Mike Dimmick18-Aug-04 3:03 
GeneralRe: Is ADO thread safe ? Pin
Hesham Amin18-Aug-04 7:14
Hesham Amin18-Aug-04 7:14 
GeneralSQL Query Performance question Pin
brdavid14-Aug-04 4:43
brdavid14-Aug-04 4:43 
GeneralRe: SQL Query Performance question Pin
Colin Angus Mackay15-Aug-04 10:26
Colin Angus Mackay15-Aug-04 10:26 
GeneralRe: SQL Query Performance question Pin
brdavid15-Aug-04 11:47
brdavid15-Aug-04 11:47 
GeneralRe: SQL Query Performance question Pin
Colin Angus Mackay15-Aug-04 12:10
Colin Angus Mackay15-Aug-04 12:10 
GeneralRe: SQL Query Performance question Pin
brdavid15-Aug-04 15:05
brdavid15-Aug-04 15:05 
GeneralRe: SQL Query Performance question Pin
Anonymous23-Aug-04 7:58
Anonymous23-Aug-04 7:58 
Try the following:
SELECT *
FROM SK_SKILLSINAGES AS sia
INNER JOIN AG_AGESINERAS AS ae
	ON sia.AgeCode = ae.AgeCode
	AND ae.Description = 'Middle Ages'
INNER JOIN SK_CATEGORYGROUPS AS cg
	ON sia.GroupCode = cg.GroupCode
INNER JOIN SK_CATEGORY AS c
	ON sia.CategoryCode = c.CategoryCode
INNER JOIN AG_ERA AS e
	ON ae.EraCode = e.EraCode
	AND e.Description = 'Rolemaster'
INNER JOIN PR_DEVELOPMENTPOINTS AS pd
	ON sia.CategoryCode = pd.CategoryCode
	AND sia.GroupCode = pd.GroupCode
	AND pd.ProfessionCode = 'ANIMIST'
LEFT JOIN SK_SKILLS AS s
	ON (sia.SkillCode = s.SkillCode)
	OR (sia.SkillCode = s.ParentSkillCode AND sia.SubSkillCode = s.SkillCode))
WHERE ( (sia.SubSkillCode Is Null AND s.ParentSkillCode Is Null)
	OR (sia.SubSkillCode Is Not Null AND s.ParentSkillCode Is Not Null)
ORDER BY sia.AgeCode, sia.GroupCode, sia.CategoryCode, sia.SkillCode, sia.SubSkillCode;

I have tried to simplify and reorder the SQL. You have a number of joins that restrict the number of records returned (e.g. your "pd.ProfessionCode = 'ANIMIST'" clause). You might want to try moving the more restrictive tables to the top of the "from" clause.

My guess is that the "or" statements involved with the link to SK_SKILLS are the big performance drain (because many databases won't bother to use the indexes) You can test this by removing that part of the statement). A possible way of getting around the "OR" problem is to use a union-join:
SELECT * FROM tables
	WHERE sia.SkillCode = s.SkillCode
UNION ALL
SELECT * FROM tables
	WHERE sia.SkillCode = s.ParentSkillCode
	AND sia.SubSkillCode = s.SkillCode
ORDER BY <columns>

This approach allows the database engine to use separate indexes for the two different links to the skills table.

Hope this helps.
Andy Harman
GeneralRe: SQL Query Performance question Pin
brdavid28-Aug-04 6:16
brdavid28-Aug-04 6:16 
QuestionC# SQL INSERT String??? Pin
gman4413-Aug-04 12:16
gman4413-Aug-04 12:16 
AnswerRe: C# SQL INSERT String??? Pin
Colin Angus Mackay13-Aug-04 12:47
Colin Angus Mackay13-Aug-04 12:47 
GeneralRe: C# SQL INSERT String??? Pin
gman4415-Aug-04 4:03
gman4415-Aug-04 4:03 
AnswerRe: C# SQL INSERT String??? Pin
S Sansanwal15-Aug-04 17:07
S Sansanwal15-Aug-04 17:07 
GeneralSELECT in UPDATE statement Pin
blopf13-Aug-04 9:28
blopf13-Aug-04 9:28 
GeneralRe: SELECT in UPDATE statement Pin
Colin Angus Mackay13-Aug-04 12:50
Colin Angus Mackay13-Aug-04 12:50 
GeneralRe: SELECT in UPDATE statement Pin
blopf15-Aug-04 4:19
blopf15-Aug-04 4:19 
GeneralRe: SELECT in UPDATE statement Pin
Mike Dimmick15-Aug-04 9:11
Mike Dimmick15-Aug-04 9:11 
GeneralRe: SELECT in UPDATE statement Pin
EdbertP15-Aug-04 22:33
EdbertP15-Aug-04 22:33 
GeneralSQL Server 2005 Notification Services Pin
James Coleman13-Aug-04 7:50
James Coleman13-Aug-04 7:50 
GeneralComlex Query vs Multiple Queries Pin
iamalik13-Aug-04 6:41
professionaliamalik13-Aug-04 6:41 
GeneralRe: Comlex Query vs Multiple Queries Pin
Chris Meech13-Aug-04 6:49
Chris Meech13-Aug-04 6:49 
GeneralRe: Comlex Query vs Multiple Queries Pin
iamalik13-Aug-04 7:14
professionaliamalik13-Aug-04 7:14 
GeneralRe: Comlex Query vs Multiple Queries Pin
Colin Angus Mackay13-Aug-04 12:54
Colin Angus Mackay13-Aug-04 12:54 
GeneralRe: Comlex Query vs Multiple Queries Pin
Steven Campbell13-Aug-04 15:36
Steven Campbell13-Aug-04 15:36 
GeneralUpdate Database Pin
jzb13-Aug-04 6:12
jzb13-Aug-04 6:12 

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.