Skip to content

Allow prepared statements to persist across returning a connection to the pool #46

Description

@andrewsensus

Expected Behavior

When returning a connection to the pool, the connection is reset. This invalidates any prepared statements. It is desired to prepare statements and continue using them if the same connection is re-acquired from the pool. In the case of certain errors (in tedious or in code using the pool), it is also desired to allow a connection to be reset.

To accomplish this, an additional parameter can be passed to Connection.release(suppressReset). When suppressReset is not passed (old behavior) or passed with a falsy value, reset the connection as was previously done. When suppressReset is passed with a truthy value (new behavior), return the connection to the pool without resetting it.

Current Behavior

When a truthy argument is passed to Connection.release, return the connection to the pool WITHOUT resetting it.

Steps to Reproduce (for bugs)

N/A

Reason For Request (for feature requests)

I've seen a notable performance improvement for certain queries when running them as prepared statements, but resetting the connection invalidates prepared statements.

Possible Solution

see SensusDa/tedious-connection-pool@35b4417ae9b6517c5bbdfbc6b2a9a21ef6a49f85

Background Details

Running code which used prepared statements and a custom version of tedious-connection-pool with changes as shown in the commit above resulted in a notable performance improvement.

Environment

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions