Skip to content

Conversation

@HwakyoungLee
Copy link

@HwakyoungLee HwakyoungLee commented May 12, 2023

by fatkodima

This PR optimizes .mark_as_read! to be roughly one query for collections and for relations.

Implements

Partly done by ledermann#93 - an optimized "one query" solution for scopes is still pending.

from ledermann#73 and fixes ledermann#80.

This is a an improvement over my previous PR ledermann#94, so probably that can be closed.

Implementation is based on INSERT ... ON CONFLICT DO ... like feature on modern databases (aka UPSERT) using gem upsert which uses native support of "upsert" or emulates if db does not provide it and allows to insert many records at once without db constraint violation.

PostgresSQL requires to have a unique constraint (just index is not sufficient) as so upsert gem, as stated on gem's readme so migration to add such was created.

@HwakyoungLee HwakyoungLee merged commit a75caf8 into grepp:master May 12, 2023
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

Successfully merging this pull request may close these issues.

Slow N+1 query

2 participants