Link to home
Start Free TrialLog in
Avatar of ordo
ordoFlag for United States of America

asked on

SQL Select

We have a SQL stored procedure that selects and returns records against a SQL DB table containing 3 million + records.

The selection logic is very simple, any record that has a created date greater than a variable that is passed in the procedure. The resulting selected record set can be as few as a couple dozen or number in the 100,000s.

The logic run for each record is extensive, to the extent that it takes a couple of seconds for each record to be processed.

Could performance be improved if we were to do a select * insert into a new table with just the subset of records that we want, and then run the logic against that limited number of records?

Thanks for your help
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

"The logic run for each record is extensive"

Can you expound on that?  What are you doing in the logic run?  Does it make more sense to store the data differently?

Without seeing the relevant sections (or an approximation of) it will be difficult to determine if you're better off using a temporary table.
Mind readers we ain't.  Copy-paste the Stored Procedure into this question in a code block, and perhaps we can help..
Avatar of ordo

ASKER

Kyle,

The logic/operations preformed against each record isn't going to change and is way to involved to bore you with. I guess my question is more related to memory usage and processor utilization.

Thanks
Avatar of ordo

ASKER

To elaborate the stored procedure simple selects about 10 columns from each record that meets the desired created date criteria.

Thanks again.
SOLUTION
Avatar of Scott Pletcher
Scott Pletcher
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ordo

ASKER

Scott,

Table is clustered by [create date] column.

Can you elaborate a little bit on your second suggestion (set-based processing)?

Thanks for your help.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ordo

ASKER

Thank you all.