Forums / Developer / MySQL Use

MySQL Use

Author Message

Laurent Dorier

Wednesday 28 July 2010 7:48:47 am

Hello everyone,

I would like to know if eZPublish is using commit/rollback features (installation with mysql ormysqli).

It looks like many parts of code could use these features, but I don't find any autocommit in eZ code...

Thanks for a quick info about that. ;)

Bertrand Dunogier

Wednesday 28 July 2010 9:05:55 am

Yes, commit / rollback are used. We don't rollback that much, but transactions are started for most atomic operations. Most...

Bertrand Dunogier
eZ Systems Engineering, Lyon
http://twitter.com/bdunogier
http://gplus.to/BertrandDunogier

Gaetano Giunta

Wednesday 28 July 2010 12:23:27 pm

Autocommit is eanbled by default on mysql. For the oracle driver, we enable it when connecting

@bd: did you mean for most non-atomic operations? ;-)

Principal Consultant International Business
Member of the Community Project Board

Laurent Dorier

Wednesday 28 July 2010 2:21:36 pm

Thanks for the quick answer. :)

Like you wrote Gaetano, autocommit is set to On by default. For this reason I was thinking to find somewhere a "SET AUTOCOMMIT = 0" in eZ code...

Maybe Bertrand could you tell me shortly how it's working. I'm maybe just blind.

Bertrand Dunogier

Thursday 29 July 2010 1:29:14 am

How it's working ? Well, quite manually: transactions are explicitely started when needed ($db->begin()), and ended after the transaction unsafe queries have been executed, using $db->commit(). If an error occurs on any of those queries, the transaction is automatically rollbacked.

And what I mean with non-atomic operations is... well, what it means: operations which aren't meant to be part of a transaction because they're not critically dependent on each other ?

Bertrand Dunogier
eZ Systems Engineering, Lyon
http://twitter.com/bdunogier
http://gplus.to/BertrandDunogier

Laurent Dorier

Thursday 29 July 2010 6:24:28 am

Thanks Bertrand,

I've seen these code lines (and use them ;) ), but I'm searching how it's working exactly with the db handler.

I've checked in lib/ezdb/classes/ezmysqlidb.php, found the query( "COMMIT" ).... but nothing to allow this COMMIT with transactions (using the set autocommit=0; stuff ).

That's the thing disturbing me.

Sorry to bug you about, and apologize for my english.
Just want to learn. ;)

Cheers
Laurent

Bertrand Dunogier

Friday 30 July 2010 12:20:01 am

No problem whatsoever with your english, Laurent. Most of us here don't speak english as their native language anyway :)

Regarding the set autocommit part, it is a bit unrelated: we indeed don't disable autocommit, because, well, there is no need to. When a query isn't considered transaction unsafe (e.g. it can be executed independantly from the previous one), we just execute the query. Now if a set of queries are interdependant on each other, we do explicitely start a transaction ($db->begin()), and as the manual says (http://dev.mysql.com/doc/refman/5.0/en/commit.html), starting a transaction will disable autocommit.

We then just execute the "transaction unsafe" queries, and commit them using $db->commit(). If an error occurs in the transaction, the query is automatically rollbacked by the DB layer. Does it make sense ?

Bertrand Dunogier
eZ Systems Engineering, Lyon
http://twitter.com/bdunogier
http://gplus.to/BertrandDunogier

Laurent Dorier

Friday 30 July 2010 1:57:11 am

Thanks a lot Bertrand !!!

It's now really clear. I was missing the point "With START TRANSACTION, autocommit remains disabled"

Sure it makes sense. Well done guys. ;)

eZ debug

Timing: Jan 18 2025 02:15:44
Script start
Timing: Jan 18 2025 02:15:44
Module start 'content'
Timing: Jan 18 2025 02:15:45
Module end 'content'
Timing: Jan 18 2025 02:15:45
Script end

Main resources:

Total runtime1.1843 sec
Peak memory usage4,096.0000 KB
Database Queries213

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0062 588.6563180.8516
Module start 'content' 0.00621.0388 769.5078645.2656
Module end 'content' 1.04500.1392 1,414.7734341.0859
Script end 1.1843  1,755.8594 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00400.3387210.0002
Check MTime0.00140.1191210.0001
Mysql Total
Database connection0.00110.091010.0011
Mysqli_queries1.102193.05772130.0052
Looping result0.00210.17322110.0000
Template Total1.157097.720.5785
Template load0.00220.189920.0011
Template processing1.154797.500120.5774
Template load and register function0.00020.013110.0002
states
state_id_array0.00110.090710.0011
state_identifier_array0.00120.102720.0006
Override
Cache load0.00200.1700430.0000
Sytem overhead
Fetch class attribute can translate value0.00130.109640.0003
Fetch class attribute name0.00130.1123100.0001
XML
Image XML parsing0.00150.130440.0004
class_abstraction
Instantiating content class attribute0.00000.0023120.0000
General
dbfile0.00420.3538330.0001
String conversion0.00000.000430.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
8content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
13content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/emphasize.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/emphasize.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/datatype/view/ezxmltags/link.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/link.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 32
 Number of unique templates used: 8

Time used to render debug report: 0.0001 secs