My current table has users a, b, c, d, e, f registered.
Then I get a full list of all registered users and it lists c, d, e, f, g h.
This means a, b have unregistered, and g, h are new registering users.
Note*: There is no event that tells me when a users registers or unregisters. Only a list of all registered users, that I don't want to access more than once a day.
My current method of updating the MySQL:
UPDATE users SET registered = -1 WHERE registered = 1;
Then I proceed to update the table with my new list of all registered users:
INSERT INTO users (id, registered) VALUES($userid[i], 1) ON DUPLICATE KEY UPDATE registered = 1;
Then I proceed to update the table flagging users who have unregistered:
UPDATE users SET registered = 0, unregistered = 1 WHERE registered = -1;
Basically using -1 as indicator that a user was registered but not anymore according to the full list;
This works fine with a small table, but takes hours with tens of thousands.
Is there a better way?
Reducing it to a few minutes would be more than acceptable.