Skip to content

Commit

Permalink
Add in additional indexes for DW. (#1357)
Browse files Browse the repository at this point in the history
  • Loading branch information
seeker25 authored Jan 5, 2024
1 parent 7ca3f7d commit 3aaa4f0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
30 changes: 30 additions & 0 deletions pay-api/migrations/versions/2024_01_05_eec11500a81e_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""Improves performance for DW summary view, from 500s -> 30s for a months worth of data.
Revision ID: eec11500a81e
Revises: 49eaec3210e0
Create Date: 2024-01-05 11:28:12.564770
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = 'eec11500a81e'
down_revision = '49eaec3210e0'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_index(op.f('ix_ejv_invoice_links_ejv_header_id'), 'ejv_invoice_links', ['ejv_header_id'], unique=False)
op.create_index(op.f('ix_ejv_invoice_links_invoice_id'), 'ejv_invoice_links', ['invoice_id'], unique=False)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_ejv_invoice_links_invoice_id'), table_name='ejv_invoice_links')
op.drop_index(op.f('ix_ejv_invoice_links_ejv_header_id'), table_name='ejv_invoice_links')
# ### end Alembic commands ###
4 changes: 2 additions & 2 deletions pay-api/src/pay_api/models/ejv_invoice_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class EjvInvoiceLink(BaseModel): # pylint: disable=too-few-public-methods
}

id = db.Column(db.Integer, primary_key=True, autoincrement=True)
invoice_id = db.Column(db.Integer, ForeignKey('invoices.id'), nullable=False)
ejv_header_id = db.Column(db.Integer, ForeignKey('ejv_headers.id'), nullable=False)
invoice_id = db.Column(db.Integer, ForeignKey('invoices.id'), nullable=False, index=True)
ejv_header_id = db.Column(db.Integer, ForeignKey('ejv_headers.id'), nullable=False, index=True)
disbursement_status_code = db.Column(db.String(20), ForeignKey('disbursement_status_codes.code'), nullable=True)
message = db.Column('message', db.String, nullable=True, index=False)
sequence = db.Column(db.Integer, nullable=True)

0 comments on commit 3aaa4f0

Please sign in to comment.