]> Cypherpunks repositories - gostls13.git/commit
database/sql: Avoid re-preparing statements when all connections are busy
authorMarko Tiikkaja <marko@joh.to>
Tue, 2 Sep 2014 16:08:41 +0000 (09:08 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Tue, 2 Sep 2014 16:08:41 +0000 (09:08 -0700)
commit90e2e2b89633770d42f2ff558588dfc53c3288c8
treeab90f5457d66b6502af82d35461b5a131a84c988
parent60447c2d951fbaf5fcd16a773d11905abae9478f
database/sql: Avoid re-preparing statements when all connections are busy

Previously, if all connections were busy, we would always
re-prepare the statement on the connection we were assigned from
the pool.  That meant that if all connections were busy most of the
time, the number of prepared statements for each connection would
keep increasing over time.

Instead, after getting a free connection, check to see if the
statement has already been prepared on it, and reuse the statement
handle if so.

LGTM=bradfitz
R=golang-codereviews, gobot, bradfitz
CC=golang-codereviews
https://golang.org/cl/116930043
src/pkg/database/sql/sql.go
src/pkg/database/sql/sql_test.go