Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poor Query Performance #19

Open
horahoradev opened this issue May 7, 2022 · 2 comments
Open

Poor Query Performance #19

horahoradev opened this issue May 7, 2022 · 2 comments

Comments

@horahoradev
Copy link
Owner

Currently, several queries perform quite badly at the scale of 160k+ videos.

  • basic home page searches (esp tag stuff)
  • recommender query (this is a given)
  • video info fetch
    We should profile the SQL here, and see if we need to e.g. add an index.
@horahoradev
Copy link
Owner Author

horahoradev commented May 7, 2022

Made various improvements

  • postgres doesn't add an index for foreign keys by default (lol), so I did that
  • various other indexes, e.g. hash index on userid for videos table (makes profile video list queries fast)
  • improved count/search SQL, removed a redundant join, improved recommender algorithm somewhat (still very slow)
  • switched to equality for tag searches, prefix for username lookups
    Search is between 10-100x faster, profile lookups are much faster now.

There's future work to be done here, recommender is still too slow, and the fuzzy search feature was good, it'd be nice to keep it if the performance isn't prohibitive. See above article for some tips; could possibly switch to doing a prefix and suffix match instead of full fuzzy match, and add a forward and reverse b-tree on tags.

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

No branches or pull requests

1 participant