Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8050115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:58:39+00:00 2026-06-05T06:58:39+00:00

I have two tables: table1 (id, name, connte) table2 (id, name, connte) They are

  • 0

I have two tables:

table1 (id, name, connte)
table2 (id, name, connte)

They are connected through table1.connte and table2.connte. And each of them contains 100 records.

Now if I want to delete a record from table1 with id = 20 and its corresponding children in table2, is it better to do the following:

   DELETE d1,d2 FROM table1 d1 INNER JOIN table2 d2 ON d1.connte= d2.connte WHERE d1.id = 20

or the following:

  select connte from table1 where id = 20
  --Store connte in a variable say aabc--
  delete from table2 where connte = aabc   -> execute this first
  delete from table1 where id = 20    -> execute this second

If there is only one parent and one child for a record that I want to delete (here table1.id =20), then isn’t it expensive to do inner join for the whole table?

I am running this query from JAVA (so JDBC), so is it more expensive (performance wise) to run multiple queries or an inner join, for the above mentioned condition?

NOTE: Assuming no referential integrity for the tables. So, I am not using cascade delete.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T06:58:40+00:00Added an answer on June 5, 2026 at 6:58 am

    It will probably be faster to do it in one query, rather than two. You are basically trying to do optimizations yourself instead of letting the DBMS do it, and generally DBMS’ are really good at this sort of stuff.

    Also, you probably won’t have to worry about delete performance for tables this small. 100 x 100 rows is still very small, so your DBMS should be able to handle this without a problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables table1 = records, table2 = duplicates. Both tables contain a
I have two very large tables, Table1 and Table2. They look like this: Table1
I have two tables [Source: table1, Destination:table2] with 3 columns each (checkbox, value1, value2).
I have two tables table1: { id, name } table2: { id, table1_id, time_added
I have two tables. Table1 and Table2 Table1 id tid 1 100 2 200
I have a mysql database with two tables: table1 (id, name, emailid) table2 (id,
I have two tables table1 and table2 table1 has the columns: id name value
I have two tables: Table1: id attr1 fk1(Table2) fk2(Table2) Table2: id name I want
I have the following two tables: Table1 ---------- ID Name 1 A 2 B
I have two tables and the following query: table1 --------- table1Id(pk) fromdate, todate, name,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.