[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mailman-cvs
Subject:    [Mailman-checkins] [Git][mailman/mailman][master] Add useful indexes on the member table
From:       Barry Warsaw <gitlab () mg ! gitlab ! com>
Date:       2015-11-21 17:50:24
Message-ID: 5650aee07f418_8fbb14b6e2c18276 () worker7 ! cluster ! gitlab ! com ! mail
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Barry Warsaw pushed to branch master at mailman / Mailman


Commits:
9708493d by Aurélien Bompard at 2015-11-21T12:42:08Z
Add useful indexes on the member table

- - - - -


3 changed files:

- + src/mailman/database/alembic/versions/33bc0099223_add_member_indexes.py
- src/mailman/model/address.py
- src/mailman/model/member.py


Changes:

=====================================
src/mailman/database/alembic/versions/33bc0099223_add_member_indexes.py
=====================================
--- /dev/null
+++ b/src/mailman/database/alembic/versions/33bc0099223_add_member_indexes.py
@@ -0,0 +1,35 @@
+"""Add member indexes
+
+Revision ID: 33bc0099223
+Revises: 42756496720
+Create Date: 2015-11-19 23:04:42.449553
+
+"""
+
+# Revision identifiers, used by Alembic.
+revision = '33bc0099223'
+down_revision = '42756496720'
+
+from alembic import op
+
+
+def upgrade():
+    op.create_index(op.f('ix_member_address_id'),
+                    'member', ['address_id'],
+                    unique=False)
+    op.create_index(op.f('ix_member_preferences_id'),
+                    'member', ['preferences_id'],
+                    unique=False)
+    op.create_index(op.f('ix_member_user_id'),
+                    'member', ['user_id'],
+                    unique=False)
+    op.create_index(op.f('ix_address_email'),
+                    'address', ['email'],
+                    unique=False)
+
+
+def downgrade():
+    op.drop_index(op.f('ix_address_email'), table_name='address')
+    op.drop_index(op.f('ix_member_user_id'), table_name='member')
+    op.drop_index(op.f('ix_member_preferences_id'), table_name='member')
+    op.drop_index(op.f('ix_member_address_id'), table_name='member')


=====================================
src/mailman/model/address.py
=====================================
--- a/src/mailman/model/address.py
+++ b/src/mailman/model/address.py
@@ -42,7 +42,7 @@ class Address(Model):
     __tablename__ = 'address'
 
     id = Column(Integer, primary_key=True)
-    email = Column(Unicode)
+    email = Column(Unicode, index=True)
     _original = Column(Unicode)
     display_name = Column(Unicode)
     _verified_on = Column('verified_on', DateTime)


=====================================
src/mailman/model/member.py
=====================================
--- a/src/mailman/model/member.py
+++ b/src/mailman/model/member.py
@@ -57,11 +57,11 @@ class Member(Model):
     list_id = Column(Unicode)
     moderation_action = Column(Enum(Action))
 
-    address_id = Column(Integer, ForeignKey('address.id'))
+    address_id = Column(Integer, ForeignKey('address.id'), index=True)
     _address = relationship('Address')
-    preferences_id = Column(Integer, ForeignKey('preferences.id'))
+    preferences_id = Column(Integer, ForeignKey('preferences.id'), index=True)
     preferences = relationship('Preferences')
-    user_id = Column(Integer, ForeignKey('user.id'))
+    user_id = Column(Integer, ForeignKey('user.id'), index=True)
     _user = relationship('User')
 
     def __init__(self, role, list_id, subscriber):



View it on GitLab: https://gitlab.com/mailman/mailman/commit/9708493d1ad982895f4250c491a04a4f575310cf

[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/9708493d1ad982895f4250c491a04a4f575310cf">9708493d</a></strong>
 <div>
<span>by Aurélien Bompard</span>
<i>at 2015-11-21T12:42:08Z</i>
</div>
<pre class='commit-message'>Add useful indexes on the member table</pre>
</li>
</ul>
<h4>3 changed files:</h4>
<ul>
<li class='file-stats'>
<a href='#diff-0'>
<span class='new-file'>
&#43;
src/mailman/database/alembic/versions/33bc0099223_add_member_indexes.py
</span>
</a>
</li>
<li class='file-stats'>
<a href='#diff-1'>
src/mailman/model/address.py
</a>
</li>
<li class='file-stats'>
<a href='#diff-2'>
src/mailman/model/member.py
</a>
</li>
</ul>
<h4>Changes:</h4>
<li id='diff-0'>
<a href='https://gitlab.com/mailman/mailman/commit/9708493d1ad982895f4250c491a04a4f575310cf#diff-0'>
 <strong>
src/mailman/database/alembic/versions/33bc0099223_add_member_indexes.py
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: \
#ffdddd">--- /dev/null </span><span style="color: #000000;background-color: \
#ddffdd">+++ b/src/mailman/database/alembic/versions/33bc0099223_add_member_indexes.py
 </span><span style="color: #aaaaaa">@@ -0,0 +1,35 @@
</span><span style="color: #000000;background-color: #ddffdd">+"""Add member indexes
+
+Revision ID: 33bc0099223
+Revises: 42756496720
+Create Date: 2015-11-19 23:04:42.449553
+
+"""
+
+# Revision identifiers, used by Alembic.
+revision = '33bc0099223'
+down_revision = '42756496720'
+
+from alembic import op
+
+
+def upgrade():
+    op.create_index(op.f('ix_member_address_id'),
+                    'member', ['address_id'],
+                    unique=False)
+    op.create_index(op.f('ix_member_preferences_id'),
+                    'member', ['preferences_id'],
+                    unique=False)
+    op.create_index(op.f('ix_member_user_id'),
+                    'member', ['user_id'],
+                    unique=False)
+    op.create_index(op.f('ix_address_email'),
+                    'address', ['email'],
+                    unique=False)
+
+
+def downgrade():
+    op.drop_index(op.f('ix_address_email'), table_name='address')
+    op.drop_index(op.f('ix_member_user_id'), table_name='member')
+    op.drop_index(op.f('ix_member_preferences_id'), table_name='member')
+    op.drop_index(op.f('ix_member_address_id'), table_name='member')
</span></code></pre>

<br>
</li>
<li id='diff-1'>
<a href='https://gitlab.com/mailman/mailman/commit/9708493d1ad982895f4250c491a04a4f575310cf#diff-1'>
 <strong>
src/mailman/model/address.py
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: \
#ffdddd">--- a/src/mailman/model/address.py </span><span style="color: \
#000000;background-color: #ddffdd">+++ b/src/mailman/model/address.py </span><span \
style="color: #aaaaaa">@@ -42,7 +42,7 @@ class Address(Model): </span>     \
__tablename__ = 'address'  
     id = Column(Integer, primary_key=True)
<span style="color: #000000;background-color: #ffdddd">-    email = Column(Unicode)
</span><span style="color: #000000;background-color: #ddffdd">+    email = \
Column(Unicode, index=True) </span>     _original = Column(Unicode)
     display_name = Column(Unicode)
     _verified_on = Column('verified_on', DateTime)
</code></pre>

<br>
</li>
<li id='diff-2'>
<a href='https://gitlab.com/mailman/mailman/commit/9708493d1ad982895f4250c491a04a4f575310cf#diff-2'>
 <strong>
src/mailman/model/member.py
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: \
#ffdddd">--- a/src/mailman/model/member.py </span><span style="color: \
#000000;background-color: #ddffdd">+++ b/src/mailman/model/member.py </span><span \
style="color: #aaaaaa">@@ -57,11 +57,11 @@ class Member(Model): </span>     list_id = \
Column(Unicode)  moderation_action = Column(Enum(Action))
 
<span style="color: #000000;background-color: #ffdddd">-    address_id = \
Column(Integer, ForeignKey('address.id')) </span><span style="color: \
#000000;background-color: #ddffdd">+    address_id = Column(Integer, \
ForeignKey('address.id'), index=True) </span>     _address = relationship('Address')
<span style="color: #000000;background-color: #ffdddd">-    preferences_id = \
Column(Integer, ForeignKey('preferences.id')) </span><span style="color: \
#000000;background-color: #ddffdd">+    preferences_id = Column(Integer, \
ForeignKey('preferences.id'), index=True) </span>     preferences = \
relationship('Preferences') <span style="color: #000000;background-color: #ffdddd">-  \
user_id = Column(Integer, ForeignKey('user.id')) </span><span style="color: \
#000000;background-color: #ddffdd">+    user_id = Column(Integer, \
ForeignKey('user.id'), index=True) </span>     _user = relationship('User')
 
     def __init__(self, role, list_id, subscriber):
</code></pre>

<br>
</li>

</div>
<div class='footer' style='margin-top: 10px;'>
<p>
&mdash;
<br>
<a href="https://gitlab.com/mailman/mailman/commit/9708493d1ad982895f4250c491a04a4f575310cf">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/9708493d1ad982895f4250c491a04a4f575310cf"}}</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