Versions Compared

Key

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

...

Fetch descendantsOmit DescendantsDirect DescendantsAll Descendants
Query/openroadm-devices/openroadm-device[@status="success"]/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)

Why does the existing solution have quadratic complexity in some cases?

The reason the existing solution is quadratic time when fetching descendants is because the path query translates into a number of SQL queries:

  1. An SQL query that returns nodes matching query criteria
  2. For each node returned from query 1: issue an SQL query to fetch that node with descendants, using a LIKE operator.

The LIKE operator has linear time complexity, as all nodes' xpaths in a given anchor need to be examined.

In the case of a query that matches all N nodes, we are issuing N queries, each with complexity O(N). Thus the overall complexity is O(N2).

Possible improvements of proposed solution

...