I have a table that will have many records (Millions). When one of the ".._ups" values is set to 0, I need to check if all the other "ups" types for that record are also 0, and delete it. This occurs because a user can cancel their "ups" of a particular type, but not of another type. If they cancel every type of "up", I want to delete the record.
The time_unit field is a time unit that changes every 5 minutes. So each vote records what time_unit it belongs to.
Is it more efficient to only search for (delete) votes with that time unit, or search for (delete) all of the votes in the (potentially huge) table? I plan on indexing time_unit. It's hard for me to test this because I don't have the records yet.
Query 1
DELETE FROM ups
WHERE time_unit = $tuid AND big_ups = 0 AND sol_ups = 0 AND blue_ups = 0;
or
Query 2
DELETE FROM ups
WHERE big_ups = 0 AND sol_ups = 0 AND blue_ups = 0;