Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed the order of update/insert for postgres #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rfdrake
Copy link
Contributor

@rfdrake rfdrake commented Apr 8, 2015

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant