[ https://issues.apache.org/jira/browse/VELOCITY-731?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13184179#comment-13184179 ]
Colin Leroy commented on VELOCITY-731: -------------------------------------- Hello, Just a heads up about this: it can slow down velosurf users a lot. For example if your model.xml defines an entity with a huge ROWSET attribute, like in: <entity name="CATEGORY"> <attribute name="products" result="rowset/PRODUCT">select PRODUCT.* from PRODUCT where CAT_ID=<CAT_ID/></attribute> </entity> If you then do in a Velocity template: #set($category = $db.CATEGORY.fetch(1)) #foreach($category.products) ... #end ##This seems constrained inline like this, but can happen when using macros for example #if($category) ... #end the #if($category) call ends up doing: TP-Processor96[1] where [1] velosurf.model.Attribute.query (Attribute.java:161) [2] velosurf.context.AttributeReference.iterator (AttributeReference.java:83) [3] java.util.AbstractCollection.toString (AbstractCollection.java:450) [4] java.lang.String.valueOf (String.java:2 615) [5] java.lang.StringBuffer.append (StringBuffer.java:220) [6] java.util.AbstractMap.toString (AbstractMap.java:598) [7] org.apache.velocity.runtime.parser.node.ASTReference.evaluate (ASTReference.java:547) [8] org.apache.velocity.runtime.parser.node.ASTExpression.evaluate (ASTExpression.java:62) [9] org.apache.velocity.runtime.parser.node.ASTIfStatement.render (ASTIfStatement.java:85) [10] org.apache.velocity.runtime.parser.node.ASTBlock.render (ASTBlock.java:72) [11] org.apache.velocity.runtime.parser.node.ASTIfStatement.render (ASTIfStatement.java:87) Setting directive.if.tostring.nullcheck = false changed the number of SQL requests done by some of our list pages, from 14000 to 1200. > Velocity 1.6 performance is degraded by introduced toString() calls > ------------------------------------------------------------------- > > Key: VELOCITY-731 > URL: https://issues.apache.org/jira/browse/VELOCITY-731 > Project: Velocity > Issue Type: Bug > Components: Engine > Affects Versions: 1.6, 1.6.1, 1.6.2 > Environment: Apache Velocity 1.6.2 > Reporter: Jörgen Rydenius > Fix For: 1.6.x, 1.7 > > Attachments: configurable_tostring_nullcheck_patch.txt > > > As part of VELOCITY-531, r686428 introduced frequent calls to toString() just > to check if toString() != null. If toString() implementations are slightly > complex, and very frequently executed, these calls will degrade the site > performance. Are they at all necessary? What kind of object would use null as > a return value for toString()? Is it possible to remove these toString() > calls from the velocity code again? -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org For additional commands, e-mail: dev-h...@velocity.apache.org