What is the cost of the application

If I use only one Statementat a time, is it worth it to cache along with mine Connection. I already cache the connection, so I could cache the statement with virtually no cost.

Essentially, I suppose I'm asking if there are any costs / overheads for creating an instruction. I fully understand the benefits of creating prepared statements. I am talking specifically about Connection.createStatement()here.

+5
source share
2 answers

Some research on the open source jdbc driver ( jtds ) offers the following overhead for each application created. I am trying to calculate the cost of creating a new Statementone every time I want to query a database, and not contain one cached and reuse it:

  • A Connection- Presumably cached so slightly.
  • A TdsCore- It looks like a protocol implementation, but it caches so little.
  • A ResultSet.
  • And ArrayListfor batch elements.
  • An ArrayListopen ResultSets.
  • Column metadata.

So, it seems that the highest share of the cost Statementis related to what is left of any requested request.

0
source

; , JDBC, SQL ..

, Statement ( PreparedStatement) . , . , .

, ( ) . , , - , , , , . , , , . , .

+4

All Articles