Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

A new solution is being proposed where each path component of the Cps Path is looked up in constant time, thus addressing performance issues.

...

Objective of

...

the proposed solution

The objective is to achieve the maximum performance for queries.As will be demonstrated by performance tests later in this document, the existing solution has the following performance characteristics:

  • For a query that will return 1 out of N items, the current best theoretical time complexity is constant, O(1). The existing solution is linear, O(N).
  • For a query that will return all N items, the current best theoretical time complexity is quadraticlinear, O(N2).

Objective of the proposed solution

The objective is to achieve the maximum performance for queries.

...

  • ). The existing solution is quadratic, O(N2).
OperationExisting solutionProposed solution
Query 1 out of NO(N)O(1)

...

Query N out

The solution proposed in this document satisfies these performance targets.

OperationExisting solutionProposed solution
Query 1 out of NO(N2)O(1N)
Query all out of NO(N2)O(N)

Implementation Proposal

Implementation Proposal

The The new approach involves adding a column to the Fragment table, storing the last path component (called xpath_component here). The new column is indexed, to allow constant-time lookups.

...

In this case, a query that matches a single device node is executed, such as this for descendant CPS path:

//openroadm-device[@device-id="C201-7-1A-14"]

or this for absolute CPS path:

/openroadm-devices/openroadm-device[@device-id="C201-7-1A-19"]

Here is a summary of test results:.

CaseQuery one out of many using descendant cps pathQuery one out of many using absolute cps path
Query//openroadm-device[@device-id="C201-7-1A-14"]/openroadm-devices/openroadm-device[@device-id="C201-7-1A-19"]
Comparison graph


Graph detail

Note: constant to within ±1 ms

Time complexity of
existing solution

O(N)O(N)
Time complexity of
proposed solution

O(N)

O(1)
Comments

This may be O(1) or O(N) depending on how many nodes are matched by the descendant
prefix. For example, it is O(N) with the above query, but O(1) when using this query:
//openroadm-devices/openroadm-device[@device-id="C201-7-1A-14"]


...

In this case, a query that matches many device nodes using an absolute cps path is executed:.

All Descendants
Fetch descendantsOmit DescendantsDirect DescendantsAll Descendants
Query/openroadm-devices/openroadm-device[@status="success"]Fetch descendantsOmit DescendantsDirect Descendants/openroadm-devices/openroadm-device[@status="success"]/openroadm-devices/openroadm-device[@status="success"]
Comparison graph

Graph detail

Time complexity of
existing solution

Unclear, as there is very high variance. Likely O(N).O(N2)O(N2)
Time complexity of
proposed solution
O(N)O(N)O(N)

...