Skip Navigation

Request for SQL experts: Lemmy PR to combine action tables

github.com Combine action tables by dullbananas · Pull Request #4459 · LemmyNet/lemmy

This should cause a huge improvement in query plans, especially for queries that previously reached the from/join collapse limits. For example, getting saved posts might now start with an index sca...

Combine action tables by dullbananas · Pull Request #4459 · LemmyNet/lemmy

Lemmy currently uses distinct tables like post_like: (post_id, person_id, score) and post_saved. Unfortunately this causes performance issues when we have to join many of these tables to create views.

One suggestion in this PR, is to combine these into a single post_action table, with a lot of optional columns depending on the action. This solution scares me a little, because I'm afraid we might lose data integrity, and many of our constraints with so many optional columns.

Is there a better way of doing this in SQL?

13

You're viewing a single thread.

13 comments
13 comments