mysql - When is it better not to use inner join? -


i have 2 tables:

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

they connected through table1.connte , table2.connte. , each of them contains 100 records.

now if want delete record table1 id = 20 , corresponding children in table2, better following:

   delete d1,d2 table1 d1 inner join table2 d2 on d1.connte= d2.connte d1.id = 20 

or following:

  select connte table1 id = 20   --store connte in variable aabc--   delete table2 connte = aabc   -> execute first   delete table1 id = 20    -> execute second 

if there 1 parent , 1 child record want delete (here table1.id =20), isn't expensive inner join whole table?

i running query java (so jdbc), more expensive (performance wise) run multiple queries or inner join, above mentioned condition?

note: assuming no referential integrity tables. so, not using cascade delete.

it faster in 1 query, rather two. trying optimizations instead of letting dbms it, , dbms' @ sort of stuff.

also, won't have worry delete performance tables small. 100 x 100 rows still small, dbms should able handle without problem.


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -