Index last_seen

This commit is contained in:
R. Miles McCain 2021-03-28 19:15:03 +00:00
parent 08b36ba69f
commit 45fd32c8ca
2 changed files with 40 additions and 1 deletions

View File

@ -0,0 +1,38 @@
# Generated by Django 3.1.7 on 2021-03-28 19:14
from django.db import migrations, models
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('analytics', '0003_auto_20200502_1227'),
]
operations = [
migrations.AlterField(
model_name='hit',
name='last_seen',
field=models.DateTimeField(default=django.utils.timezone.now),
),
migrations.AlterField(
model_name='hit',
name='start_time',
field=models.DateTimeField(db_index=True, default=django.utils.timezone.now),
),
migrations.AlterField(
model_name='session',
name='last_seen',
field=models.DateTimeField(db_index=True, default=django.utils.timezone.now),
),
migrations.AlterField(
model_name='session',
name='start_time',
field=models.DateTimeField(db_index=True, default=django.utils.timezone.now),
),
migrations.AddIndex(
model_name='session',
index=models.Index(fields=['service', '-last_seen'], name='analytics_s_service_10bb96_idx'),
),
]

View File

@ -22,7 +22,7 @@ class Session(models.Model):
# Time # Time
start_time = models.DateTimeField(default=timezone.now, db_index=True) start_time = models.DateTimeField(default=timezone.now, db_index=True)
last_seen = models.DateTimeField(default=timezone.now) last_seen = models.DateTimeField(default=timezone.now, db_index=True)
# Core request information # Core request information
user_agent = models.TextField() user_agent = models.TextField()
@ -53,6 +53,7 @@ class Session(models.Model):
ordering = ["-start_time"] ordering = ["-start_time"]
indexes = [ indexes = [
models.Index(fields=["service", "-start_time"]), models.Index(fields=["service", "-start_time"]),
models.Index(fields=["service", "-last_seen"]),
models.Index(fields=["service", "identifier"]), models.Index(fields=["service", "identifier"]),
] ]