Siebel Performance Tuning Guide > Tuning Customer Configurations > Performance Guidelines for Siebel Scripting >
Siebel Scripting Guidelines for Optimal Performance
This topic is part of Performance Guidelines for Siebel Scripting. It provides guidelines for appropriate use of Siebel scripting using Siebel eScript or Siebel VB. For more information about these and other guidelines, see:
- Siebel eScript Language Reference
- Siebel VB Language Reference
- Siebel Object Interfaces Reference
- Configuring Siebel Business Applications
The following are some guidelines for appropriate use of Siebel scripting:
- Use declarative alternatives. Generally, try all other possibilities before using scripting to accomplish a functional requirement. See also Using Declarative Alternatives to Siebel Scripting.
- Use browser scripts for simple client-side functions such as field validation. Browser scripts are best used to perform simple procedural logic on the client side, such as performing field validation, or displaying blocking messages or alerts to users. Some such uses, particularly field validation, can reduce server round trips. Using more complex browser scripts, however, might reduce performance.
For example, using Set/Get Profile attribute calls, or invoking multiple business service methods, can require more server round trips and lead to performance problems. Adding extra functionality to scripts that display messages can have a similar effect.
NOTE: Setting the Immediate Post Changes field property has a similar effect on server round trips. Use this property only for constrained picklists and calculated fields that must be updated dynamically.
- Do not return large result sets from server business services to browser scripts. Browser scripts that invoke server scripts must return simple values or a single record, and must not return large result sets.
- Minimize scripting on field-level or control-level events. Field-level or control-level events are fired more often than most other types of events. Consequently, invoking scripts from such events can dramatically impact scalability. Avoid scripting frequent events, or simplify scripts on these events. Examples of such events include BusComp_PreGetFieldValue(), WebApplet_PreCanInvokeMethod(), and WebApplet_ShowControl().
- Use simple scripts on applet-level and business component-level events. Scripts written on events for applets or business components (for example, for Change Record events) must be very simple, because such events are fired often. Complex or I/O-intensive operations in such events will adversely affect performance.
- Caching data in Siebel eScript scripts. Executing the same SQL statements from various locations in a Siebel eScript script can generate an excessive number of script API calls and a redundant number of business component queries. In order to reduce the performance impact (assuming data does not change between invocations), you can cache a limited set of data within your scripts. (In some cases, you might not want to cache data at the script level, such as if the data that needs to be cached is too complex or too large.)
- Declare your variables. Declaring your variables and specifying their data type, as appropriate, can use less memory and improve performance.
- Destroy any created objects when you no longer need them (Siebel eScript). Theoretically, the Siebel eScript interpreter takes care of object cleanup, complex code involving many layers of object instantiation can in some cases cause the interpreter not to release objects in a timely manner. Destroying or releasing objects helps to minimize the impact on resources such as server memory.
Explicit destruction of Siebel objects must occur in the procedure in which they are created. To destroy an object in Siebel eScript, set it to NULL, or set the variable that contains it to another value. It is recommended that you destroy objects in reverse order of creation; that is, destroy child objects before you destroy parent objects.
- Verify your script is defined on the appropriate method. A script that is not defined on the right method might have a performance impact. For example, if special code needs to be run at the record level when an insert or update is done, then it is better to invoke a script from BusComp_WriteRecord() rather than BusComp_SetFieldValue(). The reason for this is that SetFieldValue events are fired much more often than WriteRecord events. Limit your use of specialized invocation methods.
- Verify your script is implemented in the right view. A script that is not implemented in the right view might cause significant performance impact. Verify that this script is implemented in the right place in the configuration, based on data manipulations, navigation requirements, and business requirements in general.
- Avoid redundant repository object settings. Do not perform unnecessary object validation. Each method invocation you perform has a performance cost. Details on this issue regarding field activation, for example, are provided below.
- Use the ActivateField() method sparingly (Siebel eScript). Do not activate a field if you will not use it. Use the ActivateField() method sparingly. Using this method increases the number of columns retrieved by a query, and can lead to multiple subqueries involving joins. These operations can use a significant amount of memory, and can degrade application performance.
Do not perform any unnecessary field activation (for fields that are already active). Each method invocation you perform has a performance cost.
- Do not activate system fields, because they are already activated by default. Such fields include Created, Created By, Updated, and so on.
- Do not activate any other fields that are already active. Check the Force Active field property in Siebel Tools to see if you need to activate it.
- Use the ExecuteQuery() method sparingly (Siebel eScript). Removing calls to execute a business component, using the method ExecuteQuery(), can yield significant performance benefit. It is better practice to use shared variables to share values of specific business component records across scripts than to separately invoke ExecuteQuery() in each script.
- Use SetSearchSpec() method rather than NextRecord() method (Siebel eScript). You can improve performance by using the SetSearchSpec() method to get a specific record, rather than using the NextRecord() method to go through a list of retrieved methods until a specific record is found.
- Use ForwardOnly cursor mode (Siebel eScript). Use the ForwardOnly cursor mode for ExecuteQuery() unless ForwardBackward is required. Using ForwardBackward uses a significant amount of memory, which can degrade application performance.
- Use appropriate error handling. Appropriate error handling can help maintain optimal performance. Although error handling is important, it also has a performance cost. For additional guidelines for using error handling in scripts, see 477766.1 (Article ID) on My Oracle Support. This document was previously published as Siebel Technical Note 514.
- Avoid nested query loops. Nested query loops can involve a large number of subqueries and can significantly impact performance. Use this technique very sparingly. Implement a nested query loop in the correct order in order to minimize the number of iterations. Be aware that a nested query loop can be invoked implicitly, depending on how your script is written.
- Use the this object reference (Siebel eScript). The special object reference this is eScript shorthand for "this (the current) object." Use it in place of references to active business objects and components.
For example, in a business component event handler, you must use this in place of ActiveBusComp(), usage of which can have a significant performance impact. Refer to the following example:
this.SetSortSpec( "Account(DESCENDING)," +
" Account Location(DESCENDING)");
- Use the Switch construct (Siebel eScript). The Switch construct directs the program to choose among any number of alternatives you require, based on the value of a single variable. Using this construct offers better performance than using a series of nested If statements, and is easier to maintain.
- Use the Select Case construct (Siebel VB). The Select Case construct directs the program to choose among any number of alternatives you require, based on the value of a single variable. Using this construct offers better performance than using a series of nested If statements, and provides other benefits.
- Test your custom scripts. Make sure your scripts are fully tested and optimized, and are no more complex than required to meet your business needs.