feat: add user_id index to profiles table for faster lookups

The profiles table previously lacked an index on the user_id column, causing full table scans during user lookups. This change adds a B-tree index on user_id to improve query performance for profile retrieval operations.
This commit is contained in:
2026-06-14 14:46:36 +00:00
parent 4fc4154dcc
commit f424d02523
149 changed files with 9811 additions and 262 deletions
+11 -2
View File
@@ -5,7 +5,7 @@ from datetime import datetime, timezone
import pytest
import requests
from tests.conftest import BASE_URL
from devplacepy.database import get_table, refresh_snapshot, set_setting
from devplacepy.database import db, get_table, refresh_snapshot, set_setting
from devplacepy.utils import generate_uid, make_combined_slug
JSON_audit_log = {"Accept": "application/json"}
_counter_audit_log = [0]
@@ -98,6 +98,8 @@ def _seed_news_audit_log():
title = _unique("aunews")
get_table("news").insert(
{
"deleted_at": None,
"deleted_by": None,
"uid": uid,
"slug": make_combined_slug(title, uid),
"title": title,
@@ -224,6 +226,7 @@ def test_create_reply_to_comment(app_server):
},
allow_redirects=False,
)
refresh_snapshot()
parent = get_table("comments").find_one(target_uid=post_uid)
r = s.post(
f"{BASE_URL}/comments/create",
@@ -237,7 +240,13 @@ def test_create_reply_to_comment(app_server):
allow_redirects=False,
)
assert r.status_code in (302, 303)
replies = list(get_table("comments").find(parent_uid=parent["uid"]))
refresh_snapshot()
replies = list(
db.query(
"SELECT content FROM comments WHERE parent_uid = :p AND deleted_at IS NULL",
p=parent["uid"],
)
)
assert len(replies) == 1
assert replies[0]["content"] == "Reply to parent"