Click here to Skip to main content
15,898,222 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi Experts,
I'm request you the suggestions and ideas to accomplish my request.

in my website running all over the countries . in my work flow there is too many inserts in multiple tables , everyday all the branches, they are getting daily basis report. which i was used stored procedure to generate report. becoz there is lot of joins criteria.

my point is i've 30 branches so everyday minimum 40-50 executions will occur. my plan is single time i've execute the stored procedure then getting records for all branches and push it to one global table after that whenever client side trying to generate the report means we can get the report data from global table . because its direct (select * from globaltable where date and branch instead of so much of joins)

is this right way or please suggest me any other way to achieve this to improve system performance.

What I have tried:

Need an idea to avoid same procedure execute multiple times.
Posted
Updated 21-Jun-17 2:09am

1 solution

As SPs borned to run simultaneously you have to be creative here...
Think of something like this:
1. Check if there is a temp table by name of today date
2. No - create one and run the rest of the SP to push data into, then select data from the table
3. Yes - select data from the table
 
Share this answer
 
Comments
sencsk 21-Jun-17 8:13am    
Hi Peter, thanks for writting.. but in my case even though user can generate existing previous dates to or between a month.. there is so many time frames
Kornfeld Eliyahu Peter 21-Jun-17 8:16am    
Then wrap the SP into an other SP and run it for each day in your time frame...
Then the wrapper can return the UNION of all the relevant tables...
Other idea can be to handle a control table...
If there is no indication for the current day in the control table, then push the data to the data table and update the control table...
It will give you a single table with data for multiply days..
sencsk 21-Jun-17 8:35am    
im creating one job to insert rows every 30 mins. I'm inserting the stored procedure result to one Newtable. so is there a way to sync newtable with stored procedure output.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900