kopia lustrzana https://github.com/bugout-dev/moonstream
Merge pull request #599 from bugout-dev/postgres-indexes
Add migration for create index for speed up queries.pull/607/head
commit
c3506f921c
|
|
@ -0,0 +1,32 @@
|
||||||
|
"""Added index for address type and name of event
|
||||||
|
|
||||||
|
Revision ID: 5f5b8f19570f
|
||||||
|
Revises: f991fc7493c8
|
||||||
|
Create Date: 2022-05-04 11:32:42.309322
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = "5f5b8f19570f"
|
||||||
|
down_revision = "f991fc7493c8"
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
op.execute(
|
||||||
|
"""
|
||||||
|
CREATE INDEX ix_polygon_labels_address_label_label_data_type_and_name ON polygon_labels USING BTREE (address,label,(label_data->>'type'),(label_data->>'name'));
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
op.execute(
|
||||||
|
"""
|
||||||
|
DROP INDEX ix_polygon_labels_address_label_label_data_type_and_name;
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
@ -260,6 +260,15 @@ class PolygonLabel(Base): # type: ignore
|
||||||
DateTime(timezone=True), server_default=utcnow(), nullable=False
|
DateTime(timezone=True), server_default=utcnow(), nullable=False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Undescribed indexes
|
||||||
|
"""
|
||||||
|
Migration: alembic\versions\5f5b8f19570f_added_index_for_address_type_and_name_.py
|
||||||
|
|
||||||
|
Index: "ix_polygon_labels_address_label_label_data_type_and_name" created manually.
|
||||||
|
By fields: (address, label, (label_data->>'type'), (label_data->>'name'))
|
||||||
|
Reason: https://github.com/sqlalchemy/alembic/issues/469#issuecomment-441887478
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
class ESDFunctionSignature(Base): # type: ignore
|
class ESDFunctionSignature(Base): # type: ignore
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Ładowanie…
Reference in New Issue