Subject | Re: Stumped on SQL Indexing/Bad Plan-ing |
---|---|
Author | red_october2009 |
Post date | 2011-08-11T01:33:06Z |
Here is another SQL that is running slow for me. I think I'm probably still missing something that you are trying to teach me. Can you spot my error?
SELECT FIRST 25 SKIP 0 DISTINCT
s.OBJ_GUID, s.CMTS, s.CTK, s.REC_DSC, s.REC_ACT, s.NOTE, l.NEW_VAL, f.FLD_DSPLY_NM, t.TBL_DSPLY_NM
FROM
JET_SAV_PNT s
JOIN JET_CHG_LOG l ON l.PAR_GUID = s.OBJ_GUID
JOIN JET_FLD_NMS f ON f.TBL_NM = l.TBL_NM AND f.FLD_NM = l.FLD_NM
JOIN JET_TBL_NMS t ON t.TBL_NM = f.TBL_NM
WHERE s.CBY = 'JMA'
ORDER BY s.CMTS DESC
This takes 3.5 seconds to run. I changed the order of the joins and also made them regular joins instead of LEFT joins. Those improvements brought the execution time down to 3.5 seconds from > 9 seconds.
SELECT FIRST 25 SKIP 0 DISTINCT
s.OBJ_GUID, s.CMTS, s.CTK, s.REC_DSC, s.REC_ACT, s.NOTE, l.NEW_VAL, f.FLD_DSPLY_NM, t.TBL_DSPLY_NM
FROM
JET_SAV_PNT s
JOIN JET_CHG_LOG l ON l.PAR_GUID = s.OBJ_GUID
JOIN JET_FLD_NMS f ON f.TBL_NM = l.TBL_NM AND f.FLD_NM = l.FLD_NM
JOIN JET_TBL_NMS t ON t.TBL_NM = f.TBL_NM
WHERE s.CBY = 'JMA'
ORDER BY s.CMTS DESC
This takes 3.5 seconds to run. I changed the order of the joins and also made them regular joins instead of LEFT joins. Those improvements brought the execution time down to 3.5 seconds from > 9 seconds.