|
I don't think you need the separate query to get the counter column *unless* the count is more than 1.
When you do the insert and do *NOT* get the duplicate key (meaning the counter will be 1), MySQL reports the number of rows affected as just 1. Whereas, when you do the insert and there is a duplicate, MySQL reports that 2 rows are affected. So you would only need to go inquire about the new count when the rows affected value is not 1.
It's a minor improvement, and if most of your inserts turn out to really *be* updates, then it's not worth the coding. But if, say, 75% of your inserts are new email addresses then it might be worth it.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
|