Insert, on duplicate update in PostgreSQL?

前端 未结 16 2228
别那么骄傲
别那么骄傲 2020-11-21 04:52

Several months ago I learned from an answer on Stack Overflow how to perform multiple updates at once in MySQL using the following syntax:

INSERT INTO table          


        
16条回答
  •  粉色の甜心
    2020-11-21 05:53

    For merging small sets, using the above function is fine. However, if you are merging large amounts of data, I'd suggest looking into http://mbk.projects.postgresql.org

    The current best practice that I'm aware of is:

    1. COPY new/updated data into temp table (sure, or you can do INSERT if the cost is ok)
    2. Acquire Lock [optional] (advisory is preferable to table locks, IMO)
    3. Merge. (the fun part)

提交回复
热议问题