mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 04:53:36 +00:00
analytics: Add indexes to optimize performance of aggregation.
These indexes fix some slow queries used in updating the analytics tables, resulting in the analytics system consuming far less total resources.
This commit is contained in:
28
analytics/migrations/0008_add_count_indexes.py
Normal file
28
analytics/migrations/0008_add_count_indexes.py
Normal file
@@ -0,0 +1,28 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.5 on 2017-02-01 22:28
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('zerver', '0050_userprofile_avatar_version'),
|
||||
('analytics', '0007_remove_interval'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterIndexTogether(
|
||||
name='realmcount',
|
||||
index_together=set([('property', 'end_time')]),
|
||||
),
|
||||
migrations.AlterIndexTogether(
|
||||
name='streamcount',
|
||||
index_together=set([('property', 'realm', 'end_time')]),
|
||||
),
|
||||
migrations.AlterIndexTogether(
|
||||
name='usercount',
|
||||
index_together=set([('property', 'realm', 'end_time')]),
|
||||
),
|
||||
]
|
||||
@@ -86,6 +86,7 @@ class RealmCount(BaseCount):
|
||||
|
||||
class Meta(object):
|
||||
unique_together = ("realm", "property", "subgroup", "end_time")
|
||||
index_together = ["property", "end_time"]
|
||||
|
||||
@staticmethod
|
||||
def extended_id():
|
||||
@@ -107,6 +108,9 @@ class UserCount(BaseCount):
|
||||
|
||||
class Meta(object):
|
||||
unique_together = ("user", "property", "subgroup", "end_time")
|
||||
# This index dramatically improves the performance of
|
||||
# aggregating from users to realms
|
||||
index_together = ["property", "realm", "end_time"]
|
||||
|
||||
@staticmethod
|
||||
def extended_id():
|
||||
@@ -128,6 +132,9 @@ class StreamCount(BaseCount):
|
||||
|
||||
class Meta(object):
|
||||
unique_together = ("stream", "property", "subgroup", "end_time")
|
||||
# This index dramatically improves the performance of
|
||||
# aggregating from streams to realms
|
||||
index_together = ["property", "realm", "end_time"]
|
||||
|
||||
@staticmethod
|
||||
def extended_id():
|
||||
|
||||
Reference in New Issue
Block a user