Database schema changes

Open
#54 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Stale
Tech stack
sql
Domain
backend, databases

Research direction

Start with docs/setup.sql and reproduce the reported SELECT against a large items table to understand the current schema and query cost. Review the feeds, items, and subscriptions definitions, then trace the application code that uses feedUrl; done means the integer feedId migration and related queries remain synchronized across all three tables.

Written by the indexing model from the issue text.

Description

Seeing that a database with millions of rows in the items table, can get queries to slow down, specifically this one:

SELECT * FROM items WHERE flDeleted = FALSE AND feedUrl IN (SELECT feedUrl FROM subscriptions WHERE listName='dave') ORDER BY pubDate DESC LIMIT 175;

Which can take ~10 seconds to load, I propose we switch from using feedUrl as the primary key to an integer based key, which will help speed up the query significantly. Testing locally, the same query took about ~20ms after the switch.

Maybe for such a big change, we might as well review the setup.sql file. The following tables use feedUrl as primary key and should be changed:

  1. feeds
  2. items
  3. subscriptions

But this will also involve code changes to keep in sync the new feedId with the current feedUrl and querying feedId instead.

Dominant language
HTML
Stars
11
Forks
4
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from scripting/feedlandInstall

All issues in scripting/feedlandInstall

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.