This article provides some tips and techniques for successful complex mapping design and for enhancing mapping performance:
Always use sorted data for very large data aggregations, or use PowerCenter server 64-bit , and allocate a large amount of memory. Sorted aggregations run much faster than unsorted aggregations.
Aggregator transformations do not sort data. The aggregator uses a clustering algorithm, not a sort algorithm. When there are duplicate rows the aggregator may put data out in a seemingly sorted order but it does not guarantee it.
Keep mappings as simple as possible. The smaller the better in terms of performance and tuning. Divide and conquer is the best strategy for fastest mapping performance. Sometimes multi-staging the work, or splitting the workload between the database and stages can release dependencies upstream, and increase parallelism.
Make sure to allocate a large amount of memory (as much as possible) for mapping objects that cache.
Aggregator transformations can be used to pivot (de-normalize) data
When replacing PERL code, make sure to break the code into units of work. Use each unit as a design step in the mapping architecture. Develop the overall complex mapping, then break it apart into smaller manageable steps.
Keep the mapping objects as streamlined as possible. Run the data through the transforms, not around them. This helps with the partitioning options at the session level, as well as the parallelism capabilities of the mapping.
When using a Sort, Aggregator, Joiner, or Lookup transformation keep the keys as "small" as possible (measured in precision). Much of the same mathematics that play in computing relational database indexes also play in computing the"indexed" fields that perform the operations listed above.
Keep filter conditions simple, move the complex condition expressions into expression objects. This keeps the filter fast. When the filter runs slowly it's usually because of a complex condition.
Break complex conditions down into smaller parts. Use the variables within an expression to build complex expression logic. This keeps the mappings more maintainable.
Never have more than five (5) targets per mapping. This will slow down the mapping exponentially. Complex maps usually demand multiple targets, but the more targets you have, the poorer the performance.
Complex architectures usually require update strategies within the mapping. The update strategies can result in a performance hit to the session, sometimes significant. It is recommended to minimize the usage of Update Strategies transformations for optimal performance.
If you have very large and complex mappings that are running with a large amount of data (~50 million+ rows) then it is recommended to use the PowerCenter 64-bit server for optimal performance. It provides you with access to plenty of memory and high speed performance for large mappings.
Any mapping with 50+ objects is simply too large and MUST be broken down into multiple mappings.
To create complex output (say a mainframe ASCII file), use a single flat file, single string (4k if necessary), format the string in one or more export "expressions". Use the LPAD and RPAD functions to re-format data, and put record indicator columns on the output side.
Always set the "master" in the joiner to be the smaller of the two tables (except when using detail outer join or full outer join). This will keep the caching of the two set to the minimum number of rows.
Replace a lookup with a joiner, whenever you are faced with extremely large data sets
Use reusable lookups instead of the same lookup multiple times. This will assist in reusing the lookup caches, and improve performance.
If you are going to use a sequence generator, and share it across multiple mappings (or make the session run in parallel) then set it to cache a minimum of 10,000 values.
Optimizing PowerCenter to create an efficient execution environment.
Although PowerCenter environments vary widely, most sessions and/or mappings can benefit from the implementation of common objects and optimization procedures. Follow these procedures and rules of thumb when creating mappings to help ensure optimization.
General Suggestions for Optimizing
1. Reduce the number of transformations. There is always overhead involved in moving data between transformations.
2. Consider more shared memory for large number of transformations. Session shared memory between 12MB and 40MB should suffice.
3. Calculate once, use many times.
o Avoid calculating or testing the same value over and over.
o Calculate it once in an expression, and set a True/False flag.
o Within an expression, use variable ports to calculate a value than can be used multiple times within that transformation.
4. Only connect what is used.
o Delete unnecessary links between transformations to minimize the amount of data moved, particularly in the Source Qualifier.
o This is also helpful for maintenance. If a transformation needs to be reconnected, it is best to only have necessary ports set as input and output to reconnect.
o In lookup transformations, change unused ports to be neither input nor output. This makes the transformations cleaner looking. It also makes the generated SQL override as small as possible, which cuts down on the amount of cache necessary and thereby improves performance.
5. Watch the data types.
o The engine automatically converts compatible types.
o Sometimes data conversion is excessive. Data types are automatically converted when types are different between connected ports. Minimize data type changes between transformations by planning data flow prior to developing the mapping.
6. Facilitate reuse.
o Plan for reusable transformations upfront.
o Use variables. Use both mapping variables as well as ports that are variables. Variable ports are especially beneficial when they can be used to calculate a complex expression or perform a disconnected lookup call only once instead of multiple times
o Use mapplets to encapsulate multiple reusable transformations.
o Use mapplets to leverage the work of critical developers and minimize mistakes when performing similar functions.
7. Only manipulate data that needs to be moved and transformed.
o Reduce the number of non-essential records that are passed through the entire mapping.
o Use active transformations that reduce the number of records as early in the mapping as possible (i.e., placing filters, aggregators as close to source as possible).
o Select appropriate driving/master table while using joins. The table with the lesser number of rows should be the driving/master table for a faster join.
8. Utilize single-pass reads.
o Redesign mappings to utilize one Source Qualifier to populate multiple targets. This way the server reads this source only once. If you have different Source Qualifiers for the same source (e.g., one for delete and one for update/insert), the server reads the source for each Source Qualifier.
o Remove or reduce field-level stored procedures.
o If you use field-level stored procedures, the PowerCenter server has to make a call to that stored procedure for every row, slowing performance.
Lookup Transformation Optimizing Tips
1. When your source is large, cache lookup table columns for those lookup tables of 500,000 rows or less. This typically improves performance by 10 to 20 percent.
2. The rule of thumb is not to cache any table over 500,000 rows. This is only true if the standard row byte count is 1,024 or less. If the row byte count is more than 1,024, then the 500k rows will have to be adjusted down as the number of bytes increase (i.e., a 2,048 byte row can drop the cache row count to between 250K and 300K, so the lookup table should not be cached in this case). This is just a general rule though. Try running the session with a large lookup cached and not cached. Caching is often still faster on very large lookup tables.
3. When using a Lookup Table Transformation, improve lookup performance by placing all conditions that use the equality operator = first in the list of conditions under the condition tab.
4. Cache only lookup tables if the number of lookup calls is more than 10 to 20 percent of the lookup table rows. For fewer number of lookup calls, do not cache if the number of lookup table rows is large. For small lookup tables(i.e., less than 5,000 rows), cache for more than 5 to 10 lookup calls.
5. Replace lookup with decode or IIF (for small sets of values).
6. If caching lookups and performance is poor, consider replacing with an unconnected, uncached lookup.
7. For overly large lookup tables, use dynamic caching along with a persistent cache. Cache the entire table to a persistent file on the first run, enable the update else insert option on the dynamic cache and the engine will never have to go back to the database to read data from this table. You can also partition this persistent cache at run time for further performance gains.
8. Review complex expressions.
Examine mappings via Repository Reporting and Dependency Reporting within the mapping.
Minimize aggregate function calls.
Replace Aggregate Transformation object with an Expression Transformation object and an Update Strategy Transformation for certain types of Aggregations.
Operations and Expression Optimizing Tips
1. Numeric operations are faster than string operations.
2. Optimize char-varchar comparisons (i.e., trim spaces before comparing).
3. Operators are faster than functions (i.e., vs. CONCAT).
4. Optimize IIF expressions.
5. Avoid date comparisons in lookup; replace with string.
6. Test expression timing by replacing with constant.
7. Use flat files.
Using flat files located on the server machine loads faster than a database located in the server machine.
Fixed-width files are faster to load than delimited files because delimited files require extra parsing.
If processing intricate transformations, consider loading first to a source flat file into a relational database, which allows the PowerCenter mappings to access the data in an optimized fashion by using filters and custom SQL Selects where appropriate.
8. If working with data that is not able to return sorted data (e.g., Web Logs), consider using the Sorter Advanced External Procedure.
9. Use a Router Transformation to separate data flows instead of multiple Filter Transformations.
10. Use a Sorter Transformation or hash-auto keys partitioning before an Aggregator Transformation to optimize the aggregate. With a Sorter Transformation, the Sorted Ports option can be used, even if the original source cannot be ordered.
11. Use a Normalizer Transformation to pivot rows rather than multiple instances of the same target.
12. Rejected rows from an update strategy are logged to the bad file. Consider filtering before the update strategy if retaining these rows is not critical because logging causes extra overhead on the engine. Choose the option in the update strategy to discard rejected rows.
13. When using a Joiner Transformation, be sure to make the source with the smallest amount of data the Master source.
14. If an update override is necessary in a load, consider using a Lookup transformation just in front of the target to retrieve the primary key. The primary key update will be much faster than the non-indexed lookup override.
Suggestions for Using Mapplets
A mapplet is a reusable object that represents a set of transformations. It allows you to reuse transformation logic and can contain as many transformations as necessary. Use the Mapplet Designer to create mapplets.
1. Create a mapplet when you want to use a standardized set of transformation logic in several mappings. For example, if you have several fact tables that require a series of dimension keys, you can create a mapplet containing a series of Lookup transformations to find each dimension key. You can then use the mapplet in each fact table mapping, rather than recreate the same lookup logic in each mapping.
2. To create a mapplet, add, connect, and configure transformations to complete the desired transformation logic. After you save a mapplet, you can use it in a mapping to represent the transformations within the mapplet. When you use a mapplet in a mapping, you use an instance of the mapplet. All uses of a mapplet are tied to the parent mapplet. Hence, all changes made to the parent mapplet logic are inherited by every child instance of the mapplet. When the server runs a session using a mapplet, it expands the mapplet. The server then runs the session as it would any other session, passing data through each transformation in the mapplet as designed.
3. A mapplet can be active or passive depending on the transformations in the mapplet. Active mapplets contain at least one active transformation. Passive mapplets only contain passive transformations. Being aware of this property when using mapplets can save time when debugging invalid mappings.
4. Unsupported transformations that should not be used in a mapplet include: COBOL source definitions, normalizer, non-reusable sequence generator, pre- or post-session stored procedures, target definitions, and PowerMart 3.5-style lookup functions.
5. Do not reuse mapplets if you only need one or two transformations of the mapplet while all other calculated ports and transformations are obsolete.
6. Source data for a mapplet can originate from one of two places:
Sources within the mapplet . Use one or more source definitions connected to a Source Qualifier or ERP Source Qualifier transformation. When you use the mapplet in a mapping, the mapplet provides source data for the mapping and is the first object in the mapping data flow.
Sources outside the mapplet . Use a mapplet Input transformation to define input ports. When you use the mapplet in a mapping, data passes through the mapplet as part of the mapping data flow.
7. To pass data out of a mapplet, create mapplet output ports. Each port in an Output transformation connected to another transformation in the mapplet becomes a mapplet output port.
Active mapplets with more than one Output transformations. You need one target in the mapping for each Output transformation in the mapplet. You cannot use only one data flow of the mapplet in a mapping.
Passive mapplets with more than one Output transformations. Reduce to one Output Transformation; otherwise you need one target in the mapping for each Output transformation in the mapplet. This means you cannot use only one data flow of the mapplet in a mapping.
Minnu's Blog on Informatica & Data warehouse concepts
Monday, June 9, 2008
This article provides some tips and techniques for successful complex mapping design and for enhancing mapping performance: