Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-14750

NX_IN_TREE stored procedure does not scale on PG and mssql

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 5.9.4
    • Fix Version/s: 5.8.0-HF18, 5.9.5
    • Component/s: Core VCS
    • Tags:
    • Sprint:
      Sprint RepoTeam 5.9.5-1

      Description

      The NX_IN_TREE is an SQL stored procedure used when the PathOptimizations are disabled, this procedure does not scale.

      To get the list of children of a document the generated SQL query looks like:

      SELECT id FROM hierarchy WHERE NX_IN_TREE(id, $1)
      

      The results is O(n) where n is the number of document in the repository.
      This makes pathOptimizations (materialized path) mandatory for large volume but pathOptimizations have downsides, like creating very big table and requires complex trigger logic.

      The list of children is used:

      • on deletion to remove all children from the VCS cache
      • when using the NXQL STARTSWITH operator

      A solution is to use a Common Table Expression (CTE or CONNECT BY PRIOR on Oracle this is already done in NXP-13707). This will make the implementation O(n) where n is the number of children which is acceptable at least for the deletion use case.

      The STARTSWITH operation can be work around at higher level using Elasticsearch addon for instance.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 3 days
                  3d
                  Remaining:
                  Remaining Estimate - 3 days
                  3d
                  Logged:
                  Time Spent - Not Specified
                  Not Specified