Skip to content

USER SQL statements causing full table scans #1657

Closed

Description

@vstokesjr

The lib/user/database.php needs to be corrected.

SELECT uid, password FROM *PREFIX*users WHERE LOWER(uid) = LOWER(?)

The WHERE LOWER(uid) is causing a full table scan because it has to modify the value of the uid column to perform the comparison. This is poor SQL. The command should be:

SELECT uid, password FROM *PREFIX*users WHERE uid = LOWER(?)

And, you should modify the INSERT statement to be:

INSERT INTO *PREFIX*users ( uid, password ) VALUES( LOWER( ? ), ? )

However, most database today do not enforce case for strings (MySQL for example) unless it is specifically turned on (in most cases, it's not). Therefore the use of the LOWER() function is not required.

Activity

  1. BernhardPosselt commented on Feb 27, 2013

    @BernhardPosselt
    Contributor

    Please create a pull request.

  2. DeepDiver1975 commented on May 2, 2014

    @DeepDiver1975
    Contributor

    I guess this has been fixed with #3939

  3. locked as resolved and limited conversation to collaborators on Aug 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions