Re: WHERE clause question
From: Zach Wells (no_zwells_spam_at_ain1.com)
Date: 04/05/04
- Next message: Anith Sen: "Re: outer join 3 tables"
- Previous message: Carl Imthurn: "WHERE clause question"
- In reply to: Carl Imthurn: "WHERE clause question"
- Next in thread: Carl Imthurn: "Re: WHERE clause question"
- Reply: Carl Imthurn: "Re: WHERE clause question"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 05 Apr 2004 14:09:11 -0400
Carl Imthurn wrote:
> I am having a bit of difficulty understanding the
> performance issue I'm facing, as follows:
>
> Here's the WHERE clause of my SQL statement:
>
> WHERE
> (DN.OFFICE_NUM = 3)
> AND
> (DN.ProcedureID < 9000 OR DN.ProcedureID > 9999)
> AND
> (DN.ProcedureID <> 5985)
> AND
> (DN.PostingDate BETWEEN @StartingDate AND @EndingDate)
>
> Fairly straightforward, I thought. However, it just runs and
> runs . . . I cancelled the stored procedure
> after 5 minutes or so and started troubleshooting, and
> here's what I've been able to find out:
>
> If I comment out either one of the above lines having to do
> with DN.ProcedureID, the statement runs to completion within
> 17 seconds,
> returning the correct records (for that condition only, of
> course).
> However, I need *both* conditions to be met ( (not between
> 9000 and 9999) AND <> 5985).
>
> So. I modified the WHERE clause as follows, ran it, and went
> and did something else. Came back about 20 minutes later,
> and lo and behold! it had run to completion, in 14 minutes
> and 5 seconds, returning the exact recordset I need.
>
> WHERE
> (DN.OFFICE_NUM = 3)
> AND
> (DN.ProcedureID <> 5985 AND NOT (DN.ProcedureID BETWEEN
> 9000 AND 9999))
> AND
> (DN.PostingDate BETWEEN @StartingDate AND @EndingDate)
>
> My question --
>
> What in the world am I doing wrong to make it run so slowly?
> The column ProcedureID is indexed.
> I don't know what else to check -- I don't know a lot about
> SQL Server performance tuning,
> so any and all suggestions/help/advice will be gratefully
> accepted.
>
> Thanks --
>
> Carl
>
Couple questions:
How many rows of data in the table?
How unique is the ProcedureID data in relation to the entire table?
What type of index is on the column, clustered or non-clustered?
What other indexes exist on the table?
Zach
- Next message: Anith Sen: "Re: outer join 3 tables"
- Previous message: Carl Imthurn: "WHERE clause question"
- In reply to: Carl Imthurn: "WHERE clause question"
- Next in thread: Carl Imthurn: "Re: WHERE clause question"
- Reply: Carl Imthurn: "Re: WHERE clause question"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|