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
Combine action tables #4459
Combine action tables #4459
Conversation
Before you go forward and spend too much time on this, it needs a lot of discussion, because we could lose a lot of data integrity solely for the sake of post_view query speed. An update to a There are a lot of inside-postgres things we could do before getting rid of the |
@dessalines Would that problem be fixed by using a composite type for each action that stores multiple values? Edit: or multi-column constraints, like |
That wouldn't be better. It's not easy do to that in a way that doesn't involve checking all rows each time, and a trigger can avoid re-reading rows that don't need to be deleted. |
I will try to implement auto deletion using statements like this instead of triggers:
This statement runs successfully but I didn't test it with any rows inserted. Edit: this exact statement won't work because |
Outdated, feel free to reopen when you work on it again. |
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 scan of the post_actions table, which avoids scanning posts that the user didn't do anything with (or all non-saved posts if I add partial indexes, but I don't know if I should do that).
This will also make the code much cleaner and reduce the size of the database. (Edit: it may or may not reduce size)
Indexes for the new action tables will use
INCLUDE
WHERE
withIS NULL
for each action column to keep index-only scans possible.In the new joins, person_id will not use a bind parameter if it's
None
, so there can still be separate generic query plans for users that are not logged in.todo: constraint names, indexes, auto delete rows with no actions