Versions Compared

Key

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

Table of Contents

...

Code Block
languagesql
SELECT
    * 
FROM
    fragment 
WHERE
    parent_id =IN (
        SELECT
            id 
        FROM
            fragment 
        WHERE
            xpath_component = 'categories[@code=''1'']'
            AND parent_id =IN (
                SELECT
                    id 
                FROM
                    fragment 
                WHERE
                    xpath_component = 'bookstore'
                    AND anchor_id = 3
                    AND parent_id IS NULL
            )
        ) 
        AND (
            xpath_component = 'books'
            OR xpath_component LIKE 'books[%'
        ) 
        AND (
            attributes @> '{"price":15}'
        )

...

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

Image Modified

Graph detail

Time complexity of
existing solution

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

O(N)

O(1)
Comments

The use of LIKE 'openroadm-device[%' in the query to match candidates
means that all fragments need to be checked, e.g. for 3000 devices,
3000 x 86 ~= 250k fragments need to be scanned.

The use of the absolute path narrows the search space to only direct
children of /openroadm-devices - for 3000 devices, we only need to scan
3000 fragments instead of 250k.

...