gabriel / musehub public

0052_object_refs_object_id_index.py file-level

at sha256:3 · View file ↗ · Intel ↗

History
1 files
1 commits
0 hotspots
0 🧊 dead
0 💥 blast risk
sha256:0 fix: fall back to any indexed mpack in read_object_bytes when push mpac… · gabriel · Jun 17, 2026
1 """Add index on musehub_object_refs(object_id) for fast bulk object lookups.
2
3 The composite PK (repo_id, object_id) is optimal for queries that filter on
4 both columns. The push path queries object_refs by a large IN
5 list of object_ids (up to ~8000) with a fixed repo_id. The existing PK covers
6 this case, but an additional single-column index on object_id alone helps the
7 planner choose bitmap index scans when the IN list is large and repo_id has
8 high selectivity.
9
10 Revision ID: 0052
11 Revises: 0051
12 """
13 from __future__ import annotations
14
15 from alembic import op
16
17
18 revision: str = "0052"
19 down_revision: str = "0051"
20 branch_labels = None
21 depends_on = None
22
23
24 def upgrade() -> None:
25 op.create_index(
26 "ix_musehub_object_refs_object_id",
27 "musehub_object_refs",
28 ["object_id"],
29 unique=False,
30 )
31
32
33 def downgrade() -> None:
34 op.drop_index("ix_musehub_object_refs_object_id", table_name="musehub_object_refs")