just a real quick question

hi there.  this isn't critical at all, i'm actually just looking for other opinions as to how the following could be accomplished most appropriately.  i've got to run the code below on demand in production via procedure.  there are upwards of 88M records in prod, growing daily, and the archival does not run on this particular repository.  so, it's only getting bigger.  (at least for now, as the db design is not going to change)   So, my concern is simply design.  See the WITH (NOLOCK) and MAXDOP, I'm just trying to ensure I am not hindering other active connections when this thing is run.  you know...i don't want to invite any concurrency problems.  Any thoughts?

SELECT Symbol,
'Quantity' = CASE
    WHEN BS = 'S' THEN quantity * (-1)
    WHEN BS = 'B' THEN quantity END, [Time]
FROM ........ WITH (NOLOCK)
WHERE [Time] BETWEEN @start AND @stop
AND EndPoint IN (...........great big IN list.............)
ORDER BY [Time]
OPTION (MAXDOP 1)
LVL 18
dbaSQLAsked:
Who is Participating?
 
Kevin HillSr. SQL Server DBACommented:
maybe you create a temp table with your "great big IN list" as its rows, and join instead of doing IN?

Index on TIME?

Just some random thoughts
0
 
Aneesh RetnakaranDatabase AdministratorCommented:
When this option is in effect, it is possible to read an uncommitted transaction or a set of pages that are rolled back in the middle of a read. Dirty reads are possible.
0
 
Ved Prakash AgrawalDatabase Consultant/Performance ArchitectCommented:
Hi you can place all in values into temp variable table and then used join to get same result as you can get in IN join .
In is slow when data is more so always tried to avoid that...
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
dbaSQLAuthor Commented:
anees, are you referring to MAXDOP?
kevin/ved, yes there is an idx on time.  and the tmp table, do you feel there's a sufficient gain there?
0
 
LowfatspreadCommented:
also consider
Select symbol,
quantity * x as quantity,[time]
from ...
 Inner Join (select 'B' as BSType, 1 as x union Select 'S', -1) as Qmod
    on Qmod.BSType = BS
 Inner Join ( endpoint table ) as Ept
   on Ept.Endpt = Endpoint
where [time] between @start and @stop

order by [Time]


 Have a covering index of
  Endpoint,[Time],symbol,BS,Quantity on the table..


0
 
Aneesh RetnakaranDatabase AdministratorCommented:
> anees, are you referring to MAXDOP?

I  am referring to NOLOCK option,
0
 
Kevin HillSr. SQL Server DBACommented:
Yes....a join will typically outperform an IN list
0
 
dbaSQLAuthor Commented:
excellent.  i appreciate all of your feedback.  i will split the points
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.