MERGE INTO deduplication discussion with Wilson#85
Draft
Conversation
Owner
Author
|
The notes from postgres specify it best. Of course we don't have any Notes (copied from https://www.postgresql.org/message-id/attachment/23520/sql-merge.html) What essentially happens is that the target table is left outer-joined to the tables mentioned in the source-query, and each output row of the join may then activate at most one when-clause. The row will be matched only once per statement, so the status of MATCHED or NOT MATCHED cannot change once testing of WHEN clauses has begun. MERGE will not invoke Rules. The following steps take place during the execution of MERGE.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a demo to discuss a deduplication understanding question with Wilson no Canada on Slack.
This is the expected behavior for a
MERGE INTOcommand, according to the postgres documentation: https://www.postgresql.org/message-id/attachment/23520/sql-merge.htmlThe MERGE INTO will only deduplicate rows in
targetthat are already there.From the postgres documentation:
But
MERGE INTOis not designed to work for deduplicating records in source that come "after" records before it. It can only be used for deduplication / updating records that are already in target.