Don't flush at each put_copy_data call, but flush at get_result #462
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This better mimics, what libpq does internally.
put_copy_data
is significantly faster when it doesn'tflush
at every call. This is by a factor of 4 on Linux and 10 on Windows when sending typical per-row blocks of 60 byte.put_copy_end
unconditionally callsflush
in libpq, so it is not changed here.Also adjust
conn.block
to send all enqueued data to mimic the behavior ofget_result
in libpq. With the change toput_copy_data
, unsent data can happen, when largs blocks are sent. In this caseget_result
should catch up on flush. This is what the newly added spec verifies.PQgetResult
does flushing based on it's internal states that we don't have access to. Sinceconn.block
is performance critical in case ofsingle_row_mode
, we don't flush at every call toconn.block
, but only when it's about to wait for IO.