Skip to content

Use numeric primary keys for articles #1788

@jocmp

Description

@jocmp

The articles table currently uses id TEXT NOT NULL PRIMARY KEY where the value is the external service ID (e.g. Feedbin entry ID). This has downsides for join performance and index size compared to integer primary keys.

Current state

  • articles.id is TEXT — stores the external service ID directly
  • All child tables reference this text ID (article_statuses.article_id, saved_search_articles.article_id, enclosures.article_id, etc.)
  • Joins across these tables use text comparison

Proposed changes

  1. Add an INTEGER PRIMARY KEY AUTOINCREMENT column as the true PK
  2. Keep the external ID as external_article_id TEXT NOT NULL UNIQUE
  3. Update child table FKs to reference the integer PK
  4. Update queries and mappers accordingly

Benefits

  • SQLite INTEGER PRIMARY KEY is an alias for rowid, giving optimal storage and lookup
  • Smaller index footprint on child tables (8-byte int vs variable-length text)
  • Cleaner separation between internal identity and external service IDs

Notes

  • This is a significant migration — needs a new table + data copy approach since SQLite doesn't support altering PKs
  • All account delegates and query files will need updates
  • Should be coordinated with Enable SQLite foreign key enforcement #1787 (foreign key enforcement)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions