Skip to content

Commit d07b148

Browse files
committed
Add an index to the pending_messages table on the time field
1 parent bb3d24d commit d07b148

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""Add pending_message index on time field
2+
3+
Revision ID: 35a67ccc4451
4+
Revises: 8ece21fbeb47
5+
Create Date: 2025-09-04 08:29:17.540060
6+
7+
"""
8+
from alembic import op
9+
10+
# revision identifiers, used by Alembic.
11+
revision = '35a67ccc4451'
12+
down_revision = '8ece21fbeb47'
13+
branch_labels = None
14+
depends_on = None
15+
16+
17+
def upgrade() -> None:
18+
# ### commands auto generated by Alembic - please adjust! ###
19+
op.create_index(op.f('ix_pending_messages_time'), 'pending_messages', ['time'], unique=False)
20+
# ### end Alembic commands ###
21+
22+
23+
def downgrade() -> None:
24+
# ### commands auto generated by Alembic - please adjust! ###
25+
op.drop_index(op.f('ix_pending_messages_time'), table_name='pending_messages')
26+
# ### end Alembic commands ###

src/aleph/db/models/pending_messages.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class PendingMessageDb(Base):
5858
item_type: ItemType = Column(ChoiceType(ItemType), nullable=False)
5959
item_content = Column(String, nullable=True)
6060
content: Optional[Dict[str, Any]] = Column(JSONB, nullable=True)
61-
time: dt.datetime = Column(TIMESTAMP(timezone=True), nullable=False)
61+
time: dt.datetime = Column(TIMESTAMP(timezone=True), nullable=False, index=True)
6262
channel: Optional[Channel] = Column(String, nullable=True)
6363

6464
reception_time: dt.datetime = Column(TIMESTAMP(timezone=True), nullable=False)

0 commit comments

Comments
 (0)