[prev in list] [next in list] [prev in thread] [next in thread]
List: mailman-cvs
Subject: [Mailman-checkins] [Git][mailman/mailman][master] Optimize the roster SQL query
From: Barry Warsaw <gitlab () mg ! gitlab ! com>
Date: 2015-11-23 3:06:59
Message-ID: 565282d3b5867_5c6a152eb70304bf () worker5 ! cluster ! gitlab ! com ! mail
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Barry Warsaw pushed to branch master at mailman / Mailman
Commits:
8413ae86 by Aurélien Bompard at 2015-11-22T22:06:00Z
Optimize the roster SQL query
Measured improvement: about 100x faster. (!)
Reformatting.
- - - - -
1 changed file:
- src/mailman/model/roster.py
Changes:
=====================================
src/mailman/model/roster.py
=====================================
--- a/src/mailman/model/roster.py
+++ b/src/mailman/model/roster.py
@@ -286,9 +286,11 @@ class Memberships:
@dbconnection
def _query(self, store):
results = store.query(Member).filter(
- or_(Member.user_id == self._user.id,
- and_(Address.user_id == self._user.id,
- Member.address_id == Address.id)))
+ Member.user_id == self._user.id
+ ).union(
+ store.query(Member).join(Address).filter(
+ Address.user_id == self._user.id)
+ )
return results.distinct()
@property
View it on GitLab: https://gitlab.com/mailman/mailman/commit/8413ae86bfce8665fc94a8e3fb8b5e0624a46f25
[Attachment #5 (text/html)]
<html lang='en'>
<head>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
<title>
GitLab
</title>
</meta>
</head>
<style>
img {
max-width: 100%;
height: auto;
}
p.details {
font-style:italic;
color:#777
}
.footer p {
font-size:small;
color:#777
}
pre.commit-message {
white-space: pre-wrap;
}
.file-stats a {
text-decoration: none;
}
.file-stats .new-file {
color: #090;
}
.file-stats .deleted-file {
color: #B00;
}
</style>
<body>
<div class='content'>
<h3>Barry Warsaw pushed to branch master at <a \
href="https://gitlab.com/mailman/mailman">mailman / Mailman</a></h3> <h4>
Commits:
</h4>
<ul>
<li>
<strong><a href="https://gitlab.com/mailman/mailman/commit/8413ae86bfce8665fc94a8e3fb8b5e0624a46f25">8413ae86</a></strong>
<div>
<span>by Aurélien Bompard</span>
<i>at 2015-11-22T22:06:00Z</i>
</div>
<pre class='commit-message'>Optimize the roster SQL query
Measured improvement: about 100x faster. (!)
Reformatting.</pre>
</li>
</ul>
<h4>1 changed file:</h4>
<ul>
<li class='file-stats'>
<a href='#diff-0'>
src/mailman/model/roster.py
</a>
</li>
</ul>
<h4>Changes:</h4>
<li id='diff-0'>
<a href='https://gitlab.com/mailman/mailman/commit/8413ae86bfce8665fc94a8e3fb8b5e0624a46f25#diff-0'>
<strong>
src/mailman/model/roster.py
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: \
#ffdddd">--- a/src/mailman/model/roster.py </span><span style="color: \
#000000;background-color: #ddffdd">+++ b/src/mailman/model/roster.py </span><span \
style="color: #aaaaaa">@@ -286,9 +286,11 @@ class Memberships: </span> \
@dbconnection def _query(self, store):
results = store.query(Member).filter(
<span style="color: #000000;background-color: #ffdddd">- \
or_(Member.user_id == self._user.id,
- and_(Address.user_id == self._user.id,
- Member.address_id == Address.id)))
</span><span style="color: #000000;background-color: #ddffdd">+ \
Member.user_id == self._user.id + ).union(
+ store.query(Member).join(Address).filter(
+ Address.user_id == self._user.id)
+ )
</span> return results.distinct()
@property
</code></pre>
<br>
</li>
</div>
<div class='footer' style='margin-top: 10px;'>
<p>
—
<br>
<a href="https://gitlab.com/mailman/mailman/commit/8413ae86bfce8665fc94a8e3fb8b5e0624a46f25">View \
it on GitLab</a>. <br>
You're receiving this email because of your account on gitlab.com.
If you'd like to receive fewer emails, you can adjust your notification settings.
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View \
Commit","url":"https://gitlab.com/mailman/mailman/commit/8413ae86bfce8665fc94a8e3fb8b5e0624a46f25"}}</script>
</p>
</div>
</body>
</html>
_______________________________________________
Mailman-checkins mailing list
Mailman-checkins@python.org
Unsubscribe: https://mail.python.org/mailman/options/mailman-checkins/mailman-cvs%40progressive-comp.com
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic