I have a table with one column (about 1 million rows) :
Table A (InnoDB)
ColA (no index, no primary key)
I also have a table (3 million rows):
Table B (InnoDB)
ColA (PK INDEX) | count
Table B is a Superset of Table A. Table B contains every row I need, while Table A only contains some rows. I want to increment the count field of Table B by 1 for every row which exists in Table A. The problem is Table A is quite large so I can't use a normal UPDATE command with a where clause because the where clause would have 1 million conditions. I am really looking for the most optimized way in terms of performance to increment these fields. The solution I can think of is :
UPDATE TABLE_B set count = count + 1 where ColA IN (SELECT ColA FROM TABLE_A)
But that would require two full index scans on both tables so I am not sure if it is the fastest way to do this task.