Re: Speed dblink using alternate libpq tuple storage
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Marko Kreen <markokr@gmail.com>
Cc: Kyotaro HORIGUCHI <horiguchi.kyotaro@oss.ntt.co.jp>, greg@2ndquadrant.com, pgsql-hackers@postgresql.org, mmoncure@gmail.com, shigeru.hanada@gmail.com
Date: 2012-04-03T15:33:38Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix COPY FROM for null marker strings that correspond to invalid encoding.
- e8476f46fc84 9.2.0 cited
-
Improve labeling of pg_test_fsync open_sync test output.
- 2bbd88f8f841 9.2.0 cited
Attachments
- libpq-rowproc-20120403.patch (text/x-patch) patch
I've whacked the libpq part of this patch around to the point where I'm reasonably satisfied with it (attached), and am now looking at the dblink part. I soon realized that there's a rather nasty issue with the dblink patch, which is that it fundamentally doesn't work for async operations. In an async setup what you would do is dblink_send_query(), then periodically poll with dblink_is_busy(), then when it says the query is done, collect the results with dblink_get_result(). The trouble with this is that PQisBusy will invoke the standard row processor, so by the time dblink_get_result runs it's way too late to switch row processors. I thought about fixing that by installing dblink's custom row processor permanently, but that doesn't really work because we don't know the expected tuple column datatypes until we see the call environment for dblink_get_result(). A hack on top of that hack would be to collect the data into a tuplestore that contains all text columns, and then convert to the correct rowtype during dblink_get_result, but that seems rather ugly and not terribly high-performance. What I'm currently thinking we should do is just use the old method for async queries, and only optimize the synchronous case. I thought for awhile that this might represent a generic deficiency in the whole concept of a row processor, but probably it's mostly down to dblink's rather bizarre API. It would be unusual I think for people to want a row processor that couldn't know what to do until after the entire query result is received. regards, tom lane