SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Parallel Processing


Parallel Processing

Author
Message
Sunny-138471
Sunny-138471
Old Hand
Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)

Group: General Forum Members
Points: 302 Visits: 266
Comments posted to this topic are about the item Parallel Processing
iermis
iermis
SSC Rookie
SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)

Group: General Forum Members
Points: 30 Visits: 5
This is an excellent article the gave an idea have to solve some problems that arise from the need of paraller processing. Thank you very very much.
As all we want is right resource planning I show in the following article that its better to create temporary tables and use INSERT INTO instead of SELECT INTO. As the article says its a resources matter.
The article is here:http://www.sqlservercentral.com/articles/Basic+Querying/temptablesinsqlserver/1279/
Thank you.
iermis
iermis
SSC Rookie
SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)

Group: General Forum Members
Points: 30 Visits: 5
As I am new to SQL i cannot understand why you are using the statement
SELECT * INTO #LockHelp FROM Rainfall_Events WITH (TABLOCKX) WHERE 1=2. This statement does not fetch any rows?
I't must be somenthing about the lock time, bit can you explain me why you are using "WHERE 1=2"?
Thank you
mohd.nizamuddin
mohd.nizamuddin
Mr or Mrs. 500
Mr or Mrs. 500 (508 reputation)Mr or Mrs. 500 (508 reputation)Mr or Mrs. 500 (508 reputation)Mr or Mrs. 500 (508 reputation)Mr or Mrs. 500 (508 reputation)Mr or Mrs. 500 (508 reputation)Mr or Mrs. 500 (508 reputation)Mr or Mrs. 500 (508 reputation)

Group: General Forum Members
Points: 508 Visits: 198
iermis (10/12/2009)
As I am new to SQL i cannot understand why you are using the statement
SELECT * INTO #LockHelp FROM Rainfall_Events WITH (TABLOCKX) WHERE 1=2. This statement does not fetch any rows?
It must be something about the lock time, bit can you explain me why you are using "WHERE 1=2"?
Thank you


I think Sunny is using this "WHERE 1 = 2" for creating the #LockHelp table only, having no data.
But not sure why, because he has not refer #LockHelp in the SP.
mohd.nizamuddin
mohd.nizamuddin
Mr or Mrs. 500
Mr or Mrs. 500 (508 reputation)Mr or Mrs. 500 (508 reputation)Mr or Mrs. 500 (508 reputation)Mr or Mrs. 500 (508 reputation)Mr or Mrs. 500 (508 reputation)Mr or Mrs. 500 (508 reputation)Mr or Mrs. 500 (508 reputation)Mr or Mrs. 500 (508 reputation)

Group: General Forum Members
Points: 508 Visits: 198
Nice article. Keep it up.
Sunny-138471
Sunny-138471
Old Hand
Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)

Group: General Forum Members
Points: 302 Visits: 266
Hi iermis

Thanks for the comments.
The query you mentioned is only for getting a Table Lock on the table. We dont actually need any records from the table but at the same time we want to have the table locked from the Rest_OrphanLocks SP until the records are marked as processed. The condition "1=2" does exactly that. It does not spend time retrieving records but locks the table. #LockHelp Temporary table is optional. We could as well have a SELECT query instead of SELECT INTO

Thanks
Satish More
Sunny-138471
Sunny-138471
Old Hand
Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)

Group: General Forum Members
Points: 302 Visits: 266
mohd.nizamuddin (10/12/2009)

I think Sunny is using this "WHERE 1 = 2" for creating the #LockHelp table only, having no data.
But not sure why, because he has not refer #LockHelp in the SP.


Thanks Nizamuddin. #LockHelp is optional. You can as well have only a SELECT query instead of SELECT INTO. The only difference is that it returns an empty result set back to the SP caller

Thanks
Satish More
iermis 42311
iermis 42311
Grasshopper
Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)

Group: General Forum Members
Points: 23 Visits: 26
Thank you all for your fast replies.
:-)
Simon Facer
Simon Facer
SSCrazy
SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)

Group: General Forum Members
Points: 2129 Visits: 724
I recently (within the last 2 years) created a system to monitor our SQL instances from a central instance. Without going into details about the whole process, I had a requirement to run multiple tasks to retrieve data from the monitored instances in parallel (one or more instances unavailable would cause delays in retrieving data from all the other instances).
There's an easier way to do this than messing with lock hints, use the UPDATE ... OUTPUT format of the UPDATE query. Here's a snippet of the code that I use:

    -- ******************************************************************************************
-- Create the local temp tables used in this proc
CREATE TABLE #DRT_Update (
DataRetrievalTaskID INT)
-- ******************************************************************************************

-- ******************************************************************************************
-- Clear the temp table ...
ProcessNextServer:
DELETE #DRT_Update
-- ******************************************************************************************

-- ******************************************************************************************
-- Get the next Data Retrieval Task to be processed - set the status to 2 for the record selected.
UPDATE DataRetrievalTask
SET [Status] = 2
OUTPUT inserted.DataRetrievalTaskID
INTO #DRT_Update
WHERE DataRetrievalTaskID = (SELECT MIN(DataRetrievalTaskID)
FROM DataRetrievalTask
WHERE [Status] = 1
AND StartTime <= GETDATE() )
-- ******************************************************************************************

This process is easily scalable - I just have to create another job to execute the Stored Proc to add another process. This way, you dont have to worry about Locks etc - the SQL Engine does it for you.



iermis 42311
iermis 42311
Grasshopper
Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)

Group: General Forum Members
Points: 23 Visits: 26
Can you explain the code?
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search