Tip #15: Segments

Widely used throughout SimCorp Dimension©, Segments are used to create search conditions in various forms and windows. There are different windows for various segment types such as Auxiliary Jobs Segments, Settlement Segments, and Cost Segments, but the most widely used is the General Segments window.

Despite the distinction in the window, the underlying database tables are the same. So, if you build an extract on the segments tables, your query will return all types; this is stored in the field ‘Segment type’ in the table SEGDEFS.

When building a segment, first a table group and table are selected. It is important to first check where you need it, and what type of segment it requires. Once selected, in the search conditions you build your query.

For example:

Security type = ABS.

If there are fields you find missing, it is worth going to the Extra Search Field Conditions window and seeing if you can add them there. In this window, you can join into tables and add fields that are normally not available from the table you are using. As an example, Security Groups and Types are not available from the Holding Key table by default.

The number of fields you can select in a Cost Segment is considerably smaller than any other segment. The reason for this is for system performance reasons so as to not have cumbersome queries into underlying tables. If you find you need more fields, they can be added by going into the ‘Transaction Options’ window, selecting the tab ‘Fields’, and under ‘Fields for cost segments’ choosing the fields you need for either Transactions or Portfolio tables.

At the bottom of the Segment window, there is an option to select Save as SQL. This allows you to create your own query rather than building it from the drop downs (you can also generate SQL if you have built a query by pressing the ‘Build SQL’ button). There are pros and cons to both. Using SQL gives you more flexibility and you can reach tables and fields that might not be readily available, allowing you to create more complex solutions. But they also come at a risk of poorer system performance. If you do choose to use SQL segments, make sure to future proof them through upgrades or promotion between environments. More specifically avoid using IK values, but rather go to the underlying table where the text value exists. For example, if you need a selection of free codes, make a join into the underlying free code table.

To help you build a solid segment, it is a good idea to make use of the tools found under the function menu. The Test Segment is always a good idea to make sure you get the result you expect. If the result returned is long, try to narrow it down for your testing purposes by adding additional conditions such as portfolio = XYZ or by a security type, etc. Once it is complete, Test Performance can help ensure you don’t end up in hour-long processing times because of a segment's conditions. Generally, the ‘Time wo/key’ and ‘Time w/ key’ should be as low as possible: ideally 1.000 or lower. A higher number can be acceptable but needs to be carefully tested and observed, especially as data volumes grow. Lastly, Show Execution Plan allows you to see the underlying SQL the segment creates with additional details.

A few more comments on segments before we leave. Under the ‘File’ menu called Properties, you can control who has access to read, change, or delete each individual segments that have been set up. This is especially useful for any segments that are run in batch jobs to ensure no one accidentally changes a segment that impacts the daily batch process. For more details on this please see our previous blog Tip #10: Record Based Authorization. Also, in the ‘File’ menu you will find the Used In function, here you can check where the loaded segment or multiple segments are used, if at all. This is very useful to clean up segments, especially if you have been on SimCorp for a long time and have had colleagues come and go. It always amazes me how many segments a SimCorp installation can accumulate over the years that just clutter the usage and this is a great tool to do a little spring cleaning.

We hope this piece has been a helpful insight into ways to use and understand segments more practically. If you have any further questions or comments please leave them below.