Parallelism execution from a table - sql

I have a table with thousand of queries are waiting for execute in sql server. I am using an store procedure to execute those queries one by one. Is there any way that I can execute those queries in parallel to make the store procedure running more faster?

Related

Executing stored procedures in succession from inline SQL

I've run across code where someone wants to create a dynamic table, run a select statement to populate that table, then run a series of stored procedures using that table's data. All of this is done using inline SQL from .NET code.
What they've basically done is (pseudo code):
declare table;
insert IDs into table
exec storedprocedure table
exec storedprocedure table
exec storedprocedure table
exec storedprocedure table
In my opinion, and I don't have anything to stand on, is that this probably isn't as efficient as creating a stored procedure that does all of this and the .NET code just invokes that encapsulating stored procedure.
Are there performance hits or gains from either approach?
Are there performance hits or gains from either approach?
Not normally.
The only real difference (which is very unlikely to matter) is the size of the request data sent to the SQL Server, and the cost of hashing the TSQL batch to determine if there's a cached plan for it.
Once a cached plan is found for the TSQL batch, execution is the same as if an RPC request had invoked a stored procedure.
Another potential issue if this batch is run at a very high frequency is that the temp table metadata will not be cached. So if you're running this 1000s of times/sec and have a single tempdb file you can get metadata page latch contention in TempDb.
This is the kind of thing that sort of mattered a little a very long time ago, but which now is only noticable in edge cases.

Can I run multiple instances of the same stored procedure that includes temp tables in SQL Server

I'm trying to execute a SQL Server stored procedure through Python Pyodbc and to get the selection results printed out into .csv files. But this procedure is currently being used in other daily tasks so I'm worried that if my executing the procedure in python will interrupt the daily scheduled job process in SQL Server Agent. In the procedure, it creates several temporary tables #temp_a, #temp_b, and #temp_c. I'm wondering if these temp tables will break the scheduled jobs that include this procedure since there might be other procedures that will be creating temp table names using the same name such as #temp_a or #temp_b. The temp tables are created inside the procedure but with no delete query written. I could have tested this myself but the database I'm working on right now is just so fragile that I was told not to create tests. Thanks!
Yes
The temp-Tables will be created per Session.
I got the procedure execute by different Sessions on the same time there will be the same count of the temp-tables as sessions executed.
This temp-tables have each a different name:
#V_...._000000003EB1
#V_...._000000003EB8
The example above are the temp-Tables created by the same Procedure executed two times by different sessions at the same time.
So your scenario couldn't happen

How to run multiple SQL statements in parallel in an Oracle stored procedure

Is there a way where I can run DML statements on different tables in parallel on a Oracle database?
By in parallel I mean if I have two insert statements on table A and table B, they should both be executed at the same time (not sequentially).

SQL Server service broker to pass tables in message or share temporary tables

I have a situation where in a stored procedure a lot of select statements are being returned which are final results after a good amount of calculations.
They will execute sequentially, I guess this is taking some time. Trying to optimize the stored procedure, so one plan was to put all the select statements to servicebroker queue as dynamic SQL and execute them.
In this case if we are accessing direct tables then it is fine. As dynamic SQL will run properly but we have temporary tables in the queries which we are unable to pass to service broker.
Is there any way where we can share the temporary tables are pass them by any means.

can we execute different queries in a stored procedure same time?

In my stored procedure there are 8 queries for 8 tables.Each query has joins and sub queries. I am passing parameters & stored procedure name from
front end(designed in asp.net 3.5)
can we execute that 8 queries at the same time i.e. parallel execution so that I can minimize stored procedure execution time?
Regards,
N.SRIRAM
The stored procedure runs each each query within it sequentially. If you want to run more than one at once, you'll have to create threads in your asp.net application and run each query in it's own thread. However, due to locking and processor constraints, this may not necessarily run faster.