]> git.evergreen-ils.org Git - Evergreen.git/commit
LP#1745486: avoid retrieving user by id::numeric during auth init
authorGalen Charlton <gmc@equinoxinitiative.org>
Thu, 25 Jan 2018 21:58:33 +0000 (16:58 -0500)
committerBill Erickson <berickxx@gmail.com>
Tue, 30 Jan 2018 20:43:53 +0000 (15:43 -0500)
commit8410fdace48ceb10f0cb9e84294d15a8f5adff9a
tree3f0ec7335a03facb663df11226d79f404007aae4
parent982d999ccd391abf811f2cc4fbb0f7108b5f5fc1
LP#1745486: avoid retrieving user by id::numeric during auth init

During open-ils.auth.authenticate.init, if looking up the user by barcode,
the actor.usr row is subsequently fetched by ID. However, the ID was
turned into a float, meaning that the query as sent to the database
was equivalent to

  SELECT * FROM actor.usr WHERE id = 123.0000;

While PostgreSQL will accept this, it ends up doing a sequential
scan of the actor.usr table rather than an index lookup, making the
retrieval up to two orders of magnitude slower than it needs to be
and adding a couple percent unecessary I/O load on large, heavily
used database. This patch fixes that.

To test
-------
[1] Turn on PostgreSQL statment logging and log in as a user
    by barcode. Note that there's a retrieval of actor.usr by
    a float form of the ID.
[2] Apply the patch and repeat step 1. This time, the query
    retrieves the row by the integer form of the ID.

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/c-apps/oils_utils.c