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

Remove lower(uid) and lower(gid) from SQL queries to use the database index #13716

Closed
cdamken opened this issue Jan 27, 2015 · 14 comments
Closed

Comments

@cdamken
Copy link
Contributor

cdamken commented Jan 27, 2015

@scolebrook found some good optimizations tips here:

We've just upgraded our system to use Percona XtraDB Cluster with Cluster Control from Severalnines. We're seeing lots of queries being reported that perform full table scans. I've found some queries in 7.0.4 that could be optimized.

/core/lib/private/group/database.php line 175
The WHERE LOWER(gid) should be replaced with using lower in the insert and updates for this table so that index can be used. The index on gid is being ignored because the result of a function is being compared, not the column.

Same in /core/lib/private/user/database.php line 130 in an UPDATE query.
And line 159, this one also should see displayname added as an index on the users table.
Line 180, 210, 234 also with uid.

I see this referred to in #3939. This PR was against 6 and was never merged. It was closed about 1 year ago. The approach here was to make a column to hold a lower case version of uid in the users table. It would be populated during an upgrade and changes to this table would include writing a lower case version to this column at insert/update time. Uid is a common key and is used in many tables but the ideal solution would see this be changed in all tables at once rather than store a duplicate of the data in an additional column. However that may impact 3rd party apps so a change that big should co-inside with a major release. The lower case column was a good compromise.

Could you please bring this issue up again for us. It is poor design and very inefficient. We use ldap and even though there are hundreds of thousands of these queries daily it doesn't impact us measurably. But it produces a lot of noise in our reporting system which can hide other issues that do actually impact our performance.

@MorrisJobke @iliyasbasir

00002474

@MorrisJobke
Copy link
Contributor

@DeepDiver1975 I will try to have a look at this in the early stage of 8.1. Then I try to come up with a full migration and we have the full release cycle to find possible problems. Does this sound reasonable?

@MorrisJobke MorrisJobke self-assigned this Jan 27, 2015
@MorrisJobke MorrisJobke changed the title [7.0.4] mySQL query optimization Remove lower(uid) and lower(gid) from SQL queries to use the database index Jan 27, 2015
@MorrisJobke
Copy link
Contributor

@DeepDiver1975 Please assign to the milestone if you accept this.

@DeepDiver1975 DeepDiver1975 added this to the 8.1-next milestone Jan 28, 2015
@DeepDiver1975
Copy link
Member

data migration will be fun - repair step required.

In contrary to the approach taken in #3939 I'd lower-case the existing field and not introduce a new one.
We have to very carefull where the user id is referenced in (repeating myself - FKs would help).

THX

@PVince81
Copy link
Contributor

PVince81 commented Feb 4, 2015

"userid" is referenced in the "share_with" and "owner" columns in oc_share. Third party apps might also use such field, so might be tricky to migrate.

@DeepDiver1975
Copy link
Member

8.2 for me - we need to discuss quite some topic in the area of user management

@DeepDiver1975 DeepDiver1975 modified the milestones: 8.2-next, 8.1-current Mar 3, 2015
@DeepDiver1975 DeepDiver1975 modified the milestones: backlog, 8.2-next Jul 3, 2015
@MorrisJobke MorrisJobke removed their assignment Jul 9, 2015
@bboule
Copy link

bboule commented Jan 6, 2016

@MTRichards @cmonteroluque seems like something we need to resolve as it was opened by EE user thoughts?

@bboule bboule added the ready label Jan 6, 2016
@MTRichards
Copy link
Contributor

@cmonteroluque can we have an engineer evaluate this, or maybe @DeepDiver1975 ? I can't say if this is important or not based on the current state of oC.

@MorrisJobke
Copy link
Contributor

@cmonteroluque can we have an engineer evaluate this, or maybe @DeepDiver1975 ? I can't say if this is important or not based on the current state of oC.

The problem here is that the userid is used more often in columns that doesn't look like userid columns. For example are there now background jobs for trashbin expiry - they hold the userid as argument in the argument column of oc_jobs. The problem here is that the argument is a serialized PHP object, which makes a repair step harder.

Nothing is impossible, but I think this one will be a tough one.

@DeepDiver1975
Copy link
Member

The user accounts are a mess. period. Needs a bigger sledgehammer #21282 - which is a potential work package for 9.1.

@bboule bboule modified the milestones: 9.1-next, backlog Jan 11, 2016
@MorrisJobke
Copy link
Contributor

The user accounts are a mess. period. Needs a bigger sledgehammer #21282 - which is a potential work package for 9.1.

As this 🔨 was moved to 9.2 I will move this ticket here too. The blue ticket doesn't really apply here. I will degrade to purple.

@MorrisJobke MorrisJobke modified the milestones: 9.2-next, 9.1-current Apr 14, 2016
@MorrisJobke
Copy link
Contributor

As this 🔨 was moved to 9.2 I will move this ticket here too.

I meant #23558

@PVince81
Copy link
Contributor

@DeepDiver1975 @butonic would move to backlog for now. We anyway need #21282 first.

@PVince81 PVince81 modified the milestones: backlog, 10.0 Apr 6, 2017
@cdamken cdamken assigned hodyroff and unassigned MTRichards May 8, 2018
@hodyroff
Copy link
Contributor

hodyroff commented May 8, 2018

Performance against LDAP for users got solved and for groups it is in progress. Done as far as I can see. If there are new concrete areas for improvement, please open a new ticket.

@lock
Copy link

lock bot commented Jul 30, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants