Let's say i have two tables:
table_a:
id | article_id | text
article:
id | text
table_a for example contain data:
1 1 ""
2 1 ""
3 1 ""
4 2 ""
5 3 ""
and table articles such data:
1 ""
3 ""
as result i must in table_a left only such data:
1 1 ""
2 1 ""
3 1 ""
5 3 ""
but if i write such sql code (pseudo):
delete from table_a where article_id not in (article.id)
but main trouble is that table_a contain 40 billion entries, and articles 2 billion, and if for each table_a entry i will look up which id's are in articles and collect and then check them - it will be very long... does mysql contain any variables, which could once be filled, and then used for each table_a entry?
how could i do this task more quick, than i imagine?