Performance Tuning: Create index for boolean column

后端 未结 4 778
予麋鹿
予麋鹿 2020-12-28 13:25

I have written a daemon processor which will fetch rows from one database and insert them into another for synchronizing. It will fetch rows based on a boolean

4条回答
  •  不思量自难忘°
    2020-12-28 14:16

    For a query like this a partial index would serve you best.

    CREATE INDEX ON tbl (id) WHERE sync_done = FALSE;
    

    However, for a use case like this, other synchronization methods may be preferable to begin with:

    • Have a look at LISTEN / NOTIFY.
    • Or use a trigger in combination with dblink.
    • Or one of the many available replication methods.
      Streaming Replication was added with Postgres 9.0 and has become increasingly popular.

提交回复
热议问题