Netdot icon indicating copy to clipboard operation
Netdot copied to clipboard

changed the order of update/insert for postgres

Open rfdrake opened this issue 10 years ago • 0 comments

With the normal order, updatedevices can end up filling the postgres logs with thousands of lines like this:

2014-01-09 22:20:14 EST ERROR:  duplicate key value violates unique constraint "ipblock1"
2014-01-09 22:20:14 EST DETAIL:  Key (address, prefix)=(184398081, 32) already exists.
2014-01-09 22:20:14 EST STATEMENT:  INSERT INTO ipblock
                                              (address,prefix,version,status,first_seen,last_seen)
                                               VALUES ($1, $2, $3, $4, $5, $6)

This fixes it so UPDATE is tried first, then INSERT if no rows were updated.

rfdrake avatar Apr 08 '15 18:04 rfdrake