473,748 Members | 4,804 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DELETE query in Multi Threads

4 New Member
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 2190
roshancaptain1
14 New Member
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
ismail69
4 New Member
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 MVP
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
ismail69
4 New Member
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 MVP
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
maverick19
25 New Member
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
6459
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 results below, I would think that the delete should have deleted row 1 {1 5 me) and not row 3 (1 5 they) when I run this statement delete t1 from t, t1 where t.id = t1.id and t.id=1 and t.name = 'me'; Any ideas on why row 2 is deleted?
0
1766
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 when I try to select them out in Control Center. But when I go into the /mysql/data/mydatabase/, I see a MYD, MYI, frm for that table. And it seems that data is still inside the MYD, althought it's
4
2177
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: delete from adminpages where parentid IN ( select DISTINCT A.id from adminpages AS A where A.name='galeries' );
3
3150
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 there. There is performance degradation. The usual performance of the application on MP machine is better than that of uni processor machine. But the performance of MP degrades when it comes to the multi-threaded part of the application. I am...
1
8606
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 to be executed? I am running MySQL 4.0.20-standard. $query = "SELECT concat('DELETE FROM temp WHERE prodid = \'',prod.ProdID, '\';') AS '' FROM prod LEFT JOIN catalog ON prod.ProdID = catalog.ProdID WHERE catalog.ProdID IS NULL";
5
23356
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 solution but it is not how it must be... i think. When threads working without sleep(1) I can't get response from server but when I put sleep(1) in thread function as you will see in code, everything works fine and server can make echo nearly for...
15
8238
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 a bunch of objects from one thread and deleting them in another? I do something like: struct GenericPointerDeleter {
1
4439
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 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...
30
3838
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 the end of the app for example: class test { public: int x;
0
8830
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9544
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9324
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8243
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4606
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2783
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.