Using 'where not...' for inserts to improve upsert performance. Notably under Postgres on tables with triggers this can lead to a 10x improvement vs. using the 'on conflict' clause alone for conditional inserts. Adding to the where clause also avoids generating and then discarding values from sequences. The where clause condition should aim to use an index -- since unique indices are what cause the conflict in the first place this usually means the index needed in the where clause already exists.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Using 'where not...' for inserts to improve upsert performance. Notably under Postgres on tables with triggers this can lead to a 10x improvement vs. using the 'on conflict' clause alone for conditional inserts. Adding to the where clause also avoids generating and then discarding values from sequences. The where clause condition should aim to use an index -- since unique indices are what cause the conflict in the first place this usually means the index needed in the where clause already exists.