473,395 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

DELETE query in Multi Threads

I want to delete bunch of records from a table like,

delete from Table1 where col1 in (select col1 from Table2);

now col1 from Table2 will be some where b/w 200-500.
But Table1 will be having 3000-5000 records for a single entry from Table2.

Hence instead of deleting at a stretch, I want to get the col1 from Table2
in some Java datastructures...

And I want to delete the records using Threads.. like 5 threads at a time deleting records from Table1 for 5 entries from Table2.

I dont know whether it will work. I'm not aware of the Lock during delete operation. Please tell me whether it will work.. Or please suggest some solution..
Nov 10 '06 #1
6 2173
ya..sure it is posible to delete the values from the table...but instead of using java threads it would be better if you use triggers in database(sql)
Nov 11 '06 #2
I'm not sure.. whether DELETE statement will lock the table or not?
why because,
how it will know the diff between -
delete from Table1;

delete from Table1 where empName = "xxxx";

Here if the above statements are executed simultaneously, will it not result in error? I'm not sure abt locking mechanism.. can u please clarify?
Nov 13 '06 #3
r035198x
13,262 8TB
I want to delete bunch of records from a table like,

delete from Table1 where col1 in (select col1 from Table2);

now col1 from Table2 will be some where b/w 200-500.
But Table1 will be having 3000-5000 records for a single entry from Table2.

Hence instead of deleting at a stretch, I want to get the col1 from Table2
in some Java datastructures...

And I want to delete the records using Threads.. like 5 threads at a time deleting records from Table1 for 5 entries from Table2.

I dont know whether it will work. I'm not aware of the Lock during delete operation. Please tell me whether it will work.. Or please suggest some solution..
I am not getting the problem here. Why are you not doing:

select col1 from Table2 and store the values in an array/arraylist

Then do
for all in array
delete from Table1 where col1 = array[i];
Nov 13 '06 #4
That can be done. But that will be a serial operation.
atleast 1000 delete statements will be executed.
Each delete statements will delete atleast 5000 records.

But 5000 records deleted by one delete query is independant of all other delete statements.
Hence What I need is, If the DB2 is capable of processing concurrent delete statements, then I can issue more than one deletes at a time (using a multi thread pgm in Java). Which will improve performance I hope.

But I'm not sure whether I can do it? is it possible to execute concurrent delete statements (which will delete independant set of records)?
Nov 13 '06 #5
r035198x
13,262 8TB
That can be done. But that will be a serial operation.
atleast 1000 delete statements will be executed.
Each delete statements will delete atleast 5000 records.

But 5000 records deleted by one delete query is independant of all other delete statements.
Hence What I need is, If the DB2 is capable of processing concurrent delete statements, then I can issue more than one deletes at a time (using a multi thread pgm in Java). Which will improve performance I hope.

But I'm not sure whether I can do it? is it possible to execute concurrent delete statements (which will delete independant set of records)?
Depends on the implementation and the connection pooling then.
Nov 13 '06 #6
i think you should use stored procedures for this case
this would be far more efficient than using threads and making unnecessary objects on the heap for processing . You also dont have to worry about locking
Nov 14 '06 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Gordon | last post by:
I have 2 tables t and t1. In this case, t1 is a copy of t. I want to delete rows from t1 based on criteria on the t table and a relationship between t ad t1 (in this case the id column). In the...
0
by: Vic | last post by:
Hi all, When I test the Delete multi table function in MySQL, DELETE table_name ...] FROM table-references I accidentally delete all data in one table. All data in that table are gone...
4
by: Yossi Naggar | last post by:
Hello to everyone, I am an experienced user in MSSQL Server. Lately I have been started using MySQL. I managed to create my database and tables. When I wanted to execute the following query:...
3
by: Amit Dedhia | last post by:
Hi I am developing a Dot net application (involving image processing) on a uni processor. It works well on my machine. I then take all my code on a multi processor, build and run the application...
1
by: Dom | last post by:
Hey there, I would like to execute the following query to perform deletes. Unfortunately it only returns a list of the delete queries without actually performing them. How can I get the deletes...
5
by: Parahat Melayev | last post by:
I am trying to writa a multi-client & multi-threaded TCP server. There is a thread pool. Each thread in the pool will handle requests of multiple clients. But here I have a problem. I find a...
15
by: Dilip | last post by:
I am aware that the C++ standard in its present form does not say anything about threads, however I do have a relevant question. I am working on Windows XP/VC++ 8.0. Is there a problem new'ing...
1
by: ismail69 | last post by:
I want to delete bunch of records from a table like, delete from Table1 where col1 in (select col1 from Table2); now col1 entries from Table2 will be some where b/w 200-500. But Table1 will...
30
by: Medvedev | last post by:
i see serveral source codes , and i found they almost only use "new" and "delete" keywords to make they object. Why should i do that , and as i know the object is going to be destroy by itself at...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.