How can I speed up update/replace operations in PostgreSQL?

后端 未结 6 802
迷失自我
迷失自我 2021-02-01 06:13

We have a rather specific application that uses PostgreSQL 8.3 as a storage backend (using Python and psycopg2). The operations we perform to the important tables are in the ma

6条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-01 07:10

    The usual way I do these things in pg is: load raw data matching target table into temp table (no constraints) using copy, merge(the fun part), profit.

    I wrote a merge_by_key function specifically for these situations:

    http://mbk.projects.postgresql.org/

    The docs aren't terribly friendly, but I'd suggest giving it a good look.

提交回复
热议问题