Skip to content

Reduce sql queries for groupname tests. - #1902

Closed
dmitchell wants to merge 2 commits into
releasefrom
dhm/release-1039_0
Closed

Reduce sql queries for groupname tests.#1902
dmitchell wants to merge 2 commits into
releasefrom
dhm/release-1039_0

Conversation

@dmitchell

Copy link
Copy Markdown
Contributor

STUD-1039

@adampalay @cpennington please review

@nedbat

nedbat commented Dec 9, 2013

Copy link
Copy Markdown
Contributor

👍

1 similar comment
@adampalay

Copy link
Copy Markdown
Contributor

👍

Comment thread cms/djangoapps/auth/authz.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite understand the structure here: Will this function end up removing the user from more than one group? If so, do we want a .save() for each group? Would it work to move the .save() to after the for loop?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was mechanically editing and not thinking as clearly as you :-) I've made the change on the branch I'm progressing for the other fixes.

@adampalay adampalay mentioned this pull request Dec 10, 2013
Conflicts:
	cms/djangoapps/auth/authz.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could just do user.groups.remove(*user.groups.filter(name__in=groupnames)), which should cut it down to a single remove query (although from the previous comments, there might only be one anyway)

@cpennington

Copy link
Copy Markdown
Contributor

👍

@dmitchell

Copy link
Copy Markdown
Contributor Author

Please review this next chunk of changes: @cpennington @chrisndodge Refactored loc mapper to use SON for subdocument queries and thus the default '_id' index. (I meant to put these on a different branch building on this one, mea culpa). As far as I can tell, this reduces the mongo time by about a factor of 2. I still need to implement memoization to get rid of most of the calls (I'll do that on a branch of this one this time).

Need to have @e0d add 2 more indexes to location_map on all mongo dbs:
ensureIndex({​'_id.org': 1, '_id.course': 1}{ background:true })
ensureIndex({​'course_id': 1}{ background:true })

@chrisndodge

Copy link
Copy Markdown
Contributor

@dmitchell looking. I see test failed, but it's a locked database error. Spurious error?!?

@chrisndodge

Copy link
Copy Markdown
Contributor

Just a clarification: as a high level summary, this just makes sure the queries are hitting the indicies (thus the perf increase). This doesn't reduce # of round trips. Right?

@dmitchell

Copy link
Copy Markdown
Contributor Author

Yes, the error looked unrelated to me too.

Yes, this just ensures that every query uses the indices. I'm going to impl memoization to ensure the queries don't repeat which will curtail the round trips.

@chrisndodge

Copy link
Copy Markdown
Contributor

re: memoization, we have in the code base a "request_cache", which is a cache which has a lifetime during the span of a request. I guess it should have been named "request_scoped_cache" :-) That might be helpful for you to do this.

@chrisndodge

Copy link
Copy Markdown
Contributor

Can we ding the branch again to get a clean test pass?

+1 but you should get @cpennington to go over it as well

@adampalay

Copy link
Copy Markdown
Contributor

@dmitchell , that first commit ( 01e66ec) is already in release. #1906

@cpennington

Copy link
Copy Markdown
Contributor

👍

@dmitchell

Copy link
Copy Markdown
Contributor Author

Changed to PR against master https://github.com/edx/edx-platform/pull/1954

@dmitchell dmitchell closed this Dec 13, 2013
@adampalay

Copy link
Copy Markdown
Contributor

@dmitchell we still want this against release because we're hotfixing off of this PR

@dmitchell dmitchell reopened this Dec 13, 2013
@adampalay adampalay closed this Dec 13, 2013
@dmitchell
dmitchell deleted the dhm/release-1039_0 branch October 24, 2014 19:48
jenkins-ks pushed a commit to nttks/edx-platform that referenced this pull request Jun 23, 2017
* Fix bug 'self'. openedx#1904

* Add validation of email subject and body. openedx#1904

* Mod to get first record, if duplicate. openedx#1903

* Fix margin. openedx#1905

* Fix scrollbar and skip bok-choy. openedx#1906
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.

5 participants