Fix index names on geometry tables and add way_id/relation_id indexes

This commit is contained in:
Paul Bienkowski 2023-03-30 13:47:19 +02:00
parent 10f6b0c0c9
commit 6fb5dfe6de
4 changed files with 49 additions and 6 deletions

View file

@ -30,7 +30,9 @@ def upgrade():
sa.Column("directionality", sa.Integer),
sa.Column("oneway", sa.Boolean),
)
op.execute('CREATE INDEX ix_road_geometry ON road USING GIST (geometry) WITH (FILLFACTOR=100);')
op.execute(
"CREATE INDEX road_geometry_idx ON road USING GIST (geometry) WITH (FILLFACTOR=100);"
)
def downgrade():

View file

@ -29,7 +29,9 @@ def upgrade():
sa.Column("admin_level", sa.Integer, index=True),
sa.Column("tags", dbtype("HSTORE")),
)
op.execute('CREATE INDEX ix_region_geometry ON region USING GIST (geometry) WITH (FILLFACTOR=100);')
op.execute(
"CREATE INDEX region_geometry_idx ON region USING GIST (geometry) WITH (FILLFACTOR=100);"
)
def downgrade():

View file

@ -0,0 +1,28 @@
"""add osm id indexes
Revision ID: f4b0f460254d
Revises: b8b0fbae50a4
Create Date: 2023-03-30 10:56:22.066768
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "f4b0f460254d"
down_revision = "b8b0fbae50a4"
branch_labels = None
depends_on = None
def upgrade():
op.execute("CREATE INDEX IF NOT EXISTS ix_road_way_id ON road (way_id);")
op.execute(
"CREATE INDEX IF NOT EXISTS ix_region_relation_id ON region (relation_id);"
)
def downgrade():
op.drop_index("ix_road_way_id")
op.drop_index("ix_region_relation_id")

View file

@ -34,7 +34,7 @@ from sqlalchemy import (
select,
text,
literal,
Text
Text,
)
from sqlalchemy.dialects.postgresql import UUID
@ -166,7 +166,13 @@ class Road(Base):
import_group = Column(String)
__table_args__ = (
Index('ix_road_geometry', 'geometry', postgresql_using='gist', postgresql_with={'fillfactor':100}),
# We keep the index name as osm2pgsql created it, way back when.
Index(
"road_geometry_idx",
"geometry",
postgresql_using="gist",
postgresql_with={"fillfactor": 100},
),
)
def to_dict(self):
@ -201,7 +207,6 @@ class RoadUsage(Base):
return self.hex_hash == other.hex_hash
NOW = text("NOW()")
@ -506,7 +511,13 @@ class Region(Base):
import_group = Column(String)
__table_args__ = (
Index('ix_region_geometry', 'geometry', postgresql_using='gist', postgresql_with={'fillfactor':100}),
# We keep the index name as osm2pgsql created it, way back when.
Index(
"region_geometry_idx",
"geometry",
postgresql_using="gist",
postgresql_with={"fillfactor": 100},
),
)