From 1ad9bfcb06aec3678c345fd97103f2c73396cd44 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Mon, 28 Nov 2022 21:47:31 -0700 Subject: Add GIN index to Post.hashtags --- activities/models/post.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'activities/models') diff --git a/activities/models/post.py b/activities/models/post.py index b61abd4..f3b1879 100644 --- a/activities/models/post.py +++ b/activities/models/post.py @@ -4,6 +4,7 @@ from typing import Dict, Iterable, Optional, Set import httpx import urlman from asgiref.sync import sync_to_async +from django.contrib.postgres.indexes import GinIndex from django.db import models, transaction from django.template.defaultfilters import linebreaks_filter from django.utils import timezone @@ -187,6 +188,11 @@ class Post(StatorModel): objects = PostManager() + class Meta: + indexes = [ + GinIndex(fields=["hashtags"], name="hashtags_gin"), + ] + class urls(urlman.Urls): view = "{self.author.urls.view}posts/{self.id}/" object_uri = "{self.author.actor_uri}posts/{self.id}/" -- cgit v1.2.3