Skip to content

Add index for tiles table to improve query performance#46

Open
FryeGao wants to merge 1 commit intomapbox:masterfrom
FryeGao:add-index
Open

Add index for tiles table to improve query performance#46
FryeGao wants to merge 1 commit intomapbox:masterfrom
FryeGao:add-index

Conversation

@FryeGao
Copy link

@FryeGao FryeGao commented Oct 16, 2025

Summary

This MR adds a unique index on (zoom_level, tile_column, tile_row) in the tiles table of the MBTiles database.

Motivation

  • Querying specific tiles by (z, x, y) was previously unindexed, leading to slower lookups.
  • Adding this index significantly improves read performance and ensures data uniqueness.

Changes

  • Modified run() method in the MBTiles writer to create an index after the tiles table is created:
    cur.execute(
        "CREATE UNIQUE INDEX tile_index ON tiles (zoom_level, tile_column, tile_row);"
    )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant