Many Relationship-Links lower performance + NoAvailableRanksException

We have a performancetest for creating alot of documents+links(1000 new documents, that each have 2 links) and run some business logic on those new documents.

We have noticed that the more we run this test on an environment, the slower it gets(starting at 1m 16s to complete, up to 3m+ to complete). At some point we even get NoAvailableRanksException thrown, causing our tests to fail. Here a picture of the test runtime:

Here a quick overview of our models and how they are linked:
1 Belegliste ↔ n Beleg
1 Belegliste ↔ n Kostenart
1 Beleg ↔ n Kostenart

We are creating Beleg documents and link them to a Belegliste and a Kostenart. Each test has a new Belegliste, but we keep linking Belege to the same Kostenart.

Our suspicion is that we are adding too many links between the same Kostenart and new Belege.

Can you confirm if this is the cause of the issue? Is there anything we can do to improve the performance with alot of Belege linked to one Kostenart?

Yes, your suspicion is right. Data Services keeps a rank for every link, per document and role. All Belege (receipts) that you link to the same Kostenart (cost type) share one rank list on the Kostenart side.

Why it gets slower

For every ADD_LINK, Data Services first reads the current first or last rank of this list. The documentation describes the effect:

This algorithm requires boundary queries to determine the position of each new link relative to existing links. As the number of links grows into the tens of thousands, these boundary queries become progressively slower.

Source: Data Services documentation, Sequence Rank Strategy (2025.06-ext7, 2026.06-ext1)

Your test adds 1,000 links to the same Kostenart in every run. Therefore, the list grows with every run, and the runtime grows with it.

Why NoAvailableRanksException is thrown

The default ranks are strings with a maximum length of 255 characters. Every new link at the same end of the list uses up part of the free space at that end. I assume that the Kostenart is the first entity in your ADD_LINK request. In this case, the new link goes to the top of the Kostenart list, because position defaults to TOP. From a brief look at the code, the top of a list has room for about 6,300 links. With 1,000 links per run, this limit is reached in the 7th run.

When the space is used up, Data Services defragments the ranks of this document. However, this does not help, because the retry still uses the ranks from before the defragmentation. Therefore, every further link to this Kostenart fails with the same exception.

Solution

Data Services offers the sequence rank strategy for exactly this case. It replaces the string ranks with a PostgreSQL sequence. No boundary queries are needed, and there is no rank limit.

mgmtp.a12.dataservices.relationships.sequenceRank.enabled=true

Requirements and side effects:

  • 2025.06-ext6 with Data Services 38.4.4, 2026.06-ext1, or newer.
  • PostgreSQL.
  • It applies only to roles that are not ordered. Ordered roles still use the string ranks.
  • ADD_LINK ignores position and predecessorLinkRef for these roles.
  • Existing links keep their ranks. Only new links get sequence values. This is no problem for roles that are not ordered, because their queries sort by link ID and not by rank.

I assume that this also fixes a Kostenart that already throws the exception, because new links no longer compute a string rank.

Alternatives

  • A new Kostenart per test run, or a clean-up after each run, makes the test stable. However, this only hides the problem, because in production a Kostenart collects Belege over years.
  • "position": "BOTTOM" in ADD_LINK gives about 2.4 times more room. However, the limit stays.
  • The rank defragmentation job (mgmtp.a12.dataservices.jobs.relationships.rankRecalculation.*, disabled by default) does not help for lists that grow at the top. After a defragmentation, the top of the list has room for only 2 or 3 more links.

I would recommend to enable the sequence rank strategy, because the Kostenart list grows in production as well and has no natural upper bound.