In the world I live in, building a solution that throws all the darts at a wall, and hopes some hit the bull's eye is a pretty poor solution methodology.
So, my question arises, when is using INSERT IGNORE
in a production system acceptable by convention?
I have a situation that I'd like to write a TRIGGER
(see #17353080) that searches for existing data, if it is not found, then it is INSERTed
. A suggestion was to use INSERT IGNORE
and rely in primary keying
of unique fields.
So, I have a predicament:
- Do I use
INSERT IGNORE
and rely onprimary keying
the fields I'd like to keep unique, failing any INSERTs of repeated - Do I repeatedly query the target table to check if the field values I'd like to keep unique are present, then
INSERT
if they are not?
Since these questions are too fuzzy to ask in this specific medium, I'd like to understand when it is acceptable by convention to use INSERT IGNORE, and I can make my own judgement as to my specific case.
Thanks,
Matt
Meta:
I take it that since conventions
is an existing tag described as:
A generic tag covering any accepted method of doing things, which could include naming, spacing, coding, commenting, etc.
that questions of this type are acceptable.