2
0

Remove SelectValueTo

Benchmarks revealed that it is no longer performant enough to pull
its own wait. Using go_db_bench to copy JSON results to HTTP responses
it was ~20% *slower* for ~4BK responses and less than 10% faster for
+1MB responses.

The the performance problem was in io.CopyN / io.Copy. io.Copy
allocates a 32KB buffer if it doesn't have io.WriterTo or io.ReaderFrom
available. This extra alloc on every request was more expensive than
just reading the result into a string and writing it out to the response
body.

Tests indicated that if MsgReader implemented a custom Copy that used a
shared buffer it might have a few percent performance advantage. But the
additional complexity is not worth the performance gain.
This commit is contained in:
Jack Christensen
2014-07-05 09:25:13 -05:00
parent b27d828311
commit 5b345e80e1
7 changed files with 0 additions and 203 deletions
-8
View File
@@ -114,14 +114,6 @@ data type is to set that OID's transcoder. See
example_value_transcoder_test.go for an example of a custom transcoder for the
PostgreSQL point type.
### SelectValueTo
There are some cases where Go is used as an HTTP server that is directly
relaying single values from PostgreSQL (such as JSON or binary blobs).
SelectValueTo copies the single returned value directly from PostgreSQL to a
io.Writer. This can be faster than SelectValue then write especially when the
values are at least many KB in size.
### Null Mapping
As pgx uses interface{} for all values SQL nulls are mapped to nil. This