dbTalk Databases Forums  

No autocommit in JDBC driver? extra speed?

mailing.database.mysql-java mailing.database.mysql-java


Discuss No autocommit in JDBC driver? extra speed? in the mailing.database.mysql-java forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Kevin Burton
 
Posts: n/a

Default No autocommit in JDBC driver? extra speed? - 05-28-2004 , 05:59 PM






I enabled profileSql=true and noticed:

Query "SET autocommit=1" execution time: 33
Query "SET autocommit=1" execution time: 36
Query "SELECT * FROM FEED WHERE ID = '1'" execution time: 37
result set fetch time: 0

What's with all the autocommits? Isn't this redundant on MyISAM
tables?. Is there any way to disable this via the connection URL?

Doesn't look like it:

http://dev.mysql.com/doc/connector/j...html#id2801179

Kevin

--

Please reply using PGP.

http://peerfear.org/pubkey.asc

NewsMonster - http://www.newsmonster.org/

Kevin A. Burton, Location - San Francisco, CA, Cell - 415.595.9965
AIM/YIM - sfburtonator, Web - http://peerfear.org/
GPG fingerprint: 5FB2 F3E2 760E 70A8 6174 D393 E84D 8D04 99F1 4412
IRC - freenode.net #infoanarchy | #p2p-hackers | #newsmonster


--
MySQL Java Mailing List
For list archives: http://lists.mysql.com/java
To unsubscribe: http://lists.mysql.com/java?unsub=my...ie.nctu.edu.tw


Reply With Quote
  #2  
Old   
Kevin Burton
 
Posts: n/a

Default Re: No autocommit in JDBC driver? extra speed? - 05-28-2004 , 06:19 PM






--------------000802080305060005050409
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Kevin Burton wrote:

Quote:
I enabled profileSql=true and noticed:

Query "SET autocommit=1" execution time: 33 Query "SET
autocommit=1" execution time: 36 Query "SELECT * FROM FEED
WHERE ID = '1'" execution time: 37 result set fetch time: 0

What's with all the autocommits? Isn't this redundant on MyISAM
tables?. Is there any way to disable this via the connection URL?

Doesn't look like it:

http://dev.mysql.com/doc/connector/j...html#id2801179

Kevin

FYI... this was because we were using connection pooling. Our
persistence layer kept calling setAutoCommit( true ) which kept sending
this to the server.

The attached patch makes Connection.java smarter and if it's already
been sent and it's the same value we don't resend it. Should be simple
and clean...

Thoughts on this guy?

--

Please reply using PGP.

http://peerfear.org/pubkey.asc

NewsMonster - http://www.newsmonster.org/

Kevin A. Burton, Location - San Francisco, CA, Cell - 415.595.9965
AIM/YIM - sfburtonator, Web - http://peerfear.org/
GPG fingerprint: 5FB2 F3E2 760E 70A8 6174 D393 E84D 8D04 99F1 4412
IRC - freenode.net #infoanarchy | #p2p-hackers | #newsmonster


--------------000802080305060005050409
Content-Type: text/plain;
name="Connection.java.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="Connection.java.patch"

46d45
<
203a203,205
Quote:
/** Has autocommit already been set for this connection? */
private boolean hasAutoCommit = false;

509a512,517
//prevent duplicate autocommit settings which will just slow our
//connection to the server

if ( hasAutoCommit && this.autoCommit == autoCommit )
return;

515d522
<
548a556,557
Quote:
hasAutoCommit = true;

2724d2732
<
3129d3136
<


--------------000802080305060005050409
Content-Type: text/plain; charset=us-ascii

--
MySQL Java Mailing List
For list archives: http://lists.mysql.com/java
To unsubscribe: http://lists.mysql.com/java?unsub=my...ie.nctu.edu.tw
--------------000802080305060005050409--


Reply With Quote
  #3  
Old   
Mark Matthews
 
Posts: n/a

Default Re: No autocommit in JDBC driver? extra speed? - 05-31-2004 , 03:26 PM



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Kevin Burton wrote:

Quote:
Kevin Burton wrote:

I enabled profileSql=true and noticed:

Query "SET autocommit=1" execution time: 33 Query "SET
autocommit=1" execution time: 36 Query "SELECT * FROM FEED
WHERE ID = '1'" execution time: 37 result set fetch time: 0

What's with all the autocommits? Isn't this redundant on MyISAM
tables?. Is there any way to disable this via the connection URL?

Doesn't look like it:

http://dev.mysql.com/doc/connector/j...html#id2801179

Kevin

FYI... this was because we were using connection pooling. Our
persistence layer kept calling setAutoCommit( true ) which kept sending
this to the server.

The attached patch makes Connection.java smarter and if it's already
been sent and it's the same value we don't resend it. Should be simple
and clean...

Thoughts on this guy?



------------------------------------------------------------------------

46d45

203a203,205
/** Has autocommit already been set for this connection? */
private boolean hasAutoCommit = false;

509a512,517
//prevent duplicate autocommit settings which will just slow our
//connection to the server

if ( hasAutoCommit && this.autoCommit == autoCommit )
return;

515d522

548a556,557
hasAutoCommit = true;

2724d2732

3129d3136



Kevin,

It might be interesting, but at first glance it doesn't appear that this
patch 'knows' if auto commit has been set _outside_ of the JDBC
calls...the only 'safe' way to know this is to issue it explcitly.

This also seems like a premature optimization, are you _really_ sure the
sub-ms call to setAutoCommit() is causing your application to be slower,
compared to query optimization, caching, etc that you could do that
generally have orders-of-magnitude performance improvement possibilities?

-Mark

- --
Mr. Mark Matthews
MySQL AB, Software Development Manager, J2EE and Windows Platforms
Office: +1 708 332 0507
www.mysql.com

MySQL Guide to Lower TCO
http://www.mysql.com/it-resources/white-papers/tco.php
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFAu5TJtvXNTca6JD8RAtvpAJ9nqoUN3467rBuyfj0UO8 3N4w2pjgCeMmMg
bNHNqUgbxbjsoYLpFE95RNU=
=biCL
-----END PGP SIGNATURE-----

--
MySQL Java Mailing List
For list archives: http://lists.mysql.com/java
To unsubscribe: http://lists.mysql.com/java?unsub=my...ie.nctu.edu.tw



Reply With Quote
  #4  
Old   
Kevin Burton
 
Posts: n/a

Default Re: No autocommit in JDBC driver? extra speed? - 06-01-2004 , 02:16 PM



Mark Matthews wrote:

Quote:
Kevin,

It might be interesting, but at first glance it doesn't appear that this
patch 'knows' if auto commit has been set _outside_ of the JDBC
calls...

Oh... is there a difference if the com.mysql.* classes have set
autocommit vs external classes? It's only set once per value ... so
multiple true or false are coalesced.

From looking at the code a call from com.mysql.* vs another 3rd party
wouldn't change anything even if they were coalesced.

Quote:
the only 'safe' way to know this is to issue it explcitly.


It is issued... but we just remove duplicate SET AUTOCOMMIT=true...

Quote:
This also seems like a premature optimization, are you _really_ sure the
sub-ms call to setAutoCommit() is causing your application to be slower,
compared to query optimization, caching, etc that you could do that
generally have orders-of-magnitude performance improvement possibilities?



Oh no... let me make it clear... this isn't a HUGE performance hit it's
just wasted time for no reason.

If you run profileSql you can see it... 3ms hit per attempt.

Kevin

--

Please reply using PGP.

http://peerfear.org/pubkey.asc

NewsMonster - http://www.newsmonster.org/

Kevin A. Burton, Location - San Francisco, CA, Cell - 415.595.9965
AIM/YIM - sfburtonator, Web - http://peerfear.org/
GPG fingerprint: 5FB2 F3E2 760E 70A8 6174 D393 E84D 8D04 99F1 4412
IRC - freenode.net #infoanarchy | #p2p-hackers | #newsmonster


--
MySQL Java Mailing List
For list archives: http://lists.mysql.com/java
To unsubscribe: http://lists.mysql.com/java?unsub=my...ie.nctu.edu.tw



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.