• Marko Tiikkaja's avatar
    database/sql: Avoid re-preparing statements when all connections are busy · 90e2e2b8
    Marko Tiikkaja authored
    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
    90e2e2b8
sql_test.go 43.7 KB