the difference is that you are retrieving a large array, which you need to process (unserialize) and trawl through to get your answer. If you have the IP as a key in the table, mysql will be MUCH faster returning the answer.
I checked the manual. The command I was looking for is insert on duplicate key update or something:
*
If you specify ON DUPLICATE KEY UPDATE, and a row is inserted that would cause a duplicate value in a UNIQUE index or PRIMARY KEY, an UPDATE of the old row is performed. The affected-rows value per row is 1 if the row is inserted as a new row and 2 if an existing row is updated. See Section 12.2.4.3, “INSERT ... ON DUPLICATE KEY UPDATE Syntax”.
Inserting into a table requires the INSERT privilege for the table. If the ON DUPLICATE KEY UPDATE clause is used and a duplicate key causes an UPDATE to be performed instead, the statement requires the UPDATE privilege for the columns to be updated.
and use the IP as a key.
I do not think there are faster options. If you store the IP adress as long intereger instead of a string, storage would be not that bad. I cleaned a table the other day with 8 fields, 450K records which was 30-something MB.