Does anyone have any recommendations how to implement this?
table1 will constantly be INSERT
ed into. This necessitates that every row on table2 be UPDATE
d upon each table1 INSERT
. Also, an algorithm that I don't know if MySQL would be best responsible for (vs PHP calculation speed) also has to be applied to each row of table2.
I wanted to have PHP handle it whenever the user did the INSERT
, but I found out that PHP pages are not persistent after servering the connection to the user (or so I understand, please tell me that's wrong so I can go that route).
So now my problem is that if I use a total table UPDATE
in a TRIGGER
, I'll have locks galore (or so I understand from InnoDB's locking when UPDAT
ing an entire table with a composite primary key since part of that key will be UPDATE
d).
Now, I'm thinking of using a cron job, but I'd rather they fire upon a user's INSERT
on table1 instead of on a schedule.
So I was thinking maybe a CURSOR
...
What way would be fastest and "ABSOLUTELY" NO LOCKING on table2?
Many thanks in advance!
Table structure
table2 is all INT
s for speed. However, it has a 2 column primary key. 1 of those columns is what's being UPDATE
d. That key is for equally important rapid SELECT
s.
table1 averages about 2.5x the number of rows of table2.
table2 is actually very small, ~200mb.