In the previous article here we talked about how to properly update more than one row at a time, under the title Batch Update. We did consider performances, including network round trips, and did look at the behavior of our results when used concurrently.

A case where we want to apply the previous article approach is when
replicating data with a trigger based solution, such as SkyTools and
londiste. Well, maybe not in all cases, we need to have a amount of UPDATE
trafic worthy of setting up the solution. As soon as we know we're getting
to replay important enough batches of events, though, certainly using the
batch update tricks makes sense.
It so happens that londiste 3 includes the capability to use handlers. Those
are plugins written in python (like all the client side code from SkyTools)
whose job is to handle the processing of the event batches. Several of them
are included in the londiste sources, and one of them is named bulk.py.
Bulk loading data with londiste
To use set in londiste.ini:
handler_modules = londiste.handlers.bulk
then add table with one of those commands:
londiste3 add-table xx --handler="bulk" londiste3 add-table xx --handler="bulk(method=X)"
The default method is 0, and the available methods are the following:
correct (0)
- inserts as
COPYinto table - update as
COPYinto temp table and singleUPDATEfrom there - delete as
COPYinto temp table and singleDELETEfrom there
delete (1)
- as correct, but update are done as
DELETEthenCOPY
merged (2)
- as delete, but merge insert rows with update rows
Conclusion

Yes, by using that handler which is provided by default in londiste, you will apply the previous article tricks in your replication solution. And you can even choose to use that for only some of the tables you are replicating.
Tags
Previous Articles
- PostgreSQL HyperLogLog Monday, February 25 2013, 10:23
- HyperLogLog Unions Tuesday, February 26 2013, 12:44
- Emacs Conference Monday, March 04 2013, 13:58
- Batch Update Friday, March 15 2013, 10:47
Next Articles
- The Need For Speed Friday, March 29 2013, 09:49
- Emacs Conference Tuesday, April 02 2013, 09:56
- Nearest Big City Thursday, May 02 2013, 11:34
- from Parsing to Compiling Monday, May 13 2013, 11:08

