core/db: Improve I/O When Updating Rows
authorMichael L. Young <elgueromexicano@gmail.com>
Tue, 22 Jul 2014 18:56:00 +0000 (18:56 +0000)
committerMichael L. Young <elgueromexicano@gmail.com>
Tue, 22 Jul 2014 18:56:00 +0000 (18:56 +0000)
commitb4a681684d2fee800add540ede399bf45915fe49
tree7435cab7ec150c952f79206e43fc4a10d016ef5d
parent197f06bed16cf1babf18a1c611b99ff98aa559e4
core/db: Improve I/O When Updating Rows

When updating a row, we are currently doing an INSERT OR REPLACE INTO.  The
downside to this is that the row is deleted if it exists and then a new row is
inserted.  So, we are hitting the disk twice.  One for the deletion and one for
the insertion.

This patch changes this statement to an INSERT INTO and if the insert fails
because a row with that key exists, we will IGNORE the failure.  Then we will
attempt to perform an UPDATE on the existing row if that row wasn't just
INSERTed.

ASTERISK-24050 #close
Reported by: Michael L. Young
patches:
  astdb-insert-update-io-help_trunk_v2.diff
                                     uploaded by Michael L. Young (license 5026)

Review: https://reviewboard.asterisk.org/r/3815/

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419222 65c4cc65-6c06-0410-ace0-fbb531ad65f3
include/asterisk/astdb.h
main/db.c