Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-53420

[N1QL][UDF] subquery udf is not caching properly

    XMLWordPrintable

Details

    • Untriaged
    • 1
    • Yes

    Description

      simple repro

      install travel-sample

      CREATE OR REPLACE FUNCTION func4()

      { (SELECT RAW t1.geo.alt FROM `travel-sample`) }

      SELECT array_length(func4()) FROM `travel-sample`

      ^ the above query now takes much longer than before due to the fix for MB-53372, it now hits the 10 min timeout, in 7.1.2-3419 it took about 9 seconds

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            marco.greco Marco Greco added a comment -

            The issue here is that the UDF runner tries to determine if the subquery results should be cached based on whether the UDF takes parameters and the subquery is correlated.
            In this case the answer is no in both cases, so the query result can be cached at the request level, but the fix to MB-53372 is partial and only checks if the parameter list is nil, and not if it has zero length.
            The net result is that a corner case, where the UDF scans lots of documents (people shouldn't really be doing this, but still), and it is executed over lots of documents (people shouldn't be doing this, but still), now will take lots of time.
            The fix is to extend the test of the parameter list.

            To summarize - change in behaviour from 7.1.1, shouldn't happen a lot, when it happens it will be very annoying, easy fix.

            marco.greco Marco Greco added a comment - The issue here is that the UDF runner tries to determine if the subquery results should be cached based on whether the UDF takes parameters and the subquery is correlated. In this case the answer is no in both cases, so the query result can be cached at the request level, but the fix to MB-53372 is partial and only checks if the parameter list is nil, and not if it has zero length. The net result is that a corner case, where the UDF scans lots of documents (people shouldn't really be doing this, but still), and it is executed over lots of documents (people shouldn't be doing this, but still), now will take lots of time. The fix is to extend the test of the parameter list. To summarize - change in behaviour from 7.1.1, shouldn't happen a lot, when it happens it will be very annoying, easy fix.

            Build couchbase-server-7.2.0-1852 contains query commit a85b778 with commit message:
            MB-53420 consider empty non nil parameter list for inline UDF caching

            build-team Couchbase Build Team added a comment - Build couchbase-server-7.2.0-1852 contains query commit a85b778 with commit message: MB-53420 consider empty non nil parameter list for inline UDF caching

            Build couchbase-server-7.1.2-3421 contains query commit a486b26 with commit message:
            MB-53420 consider empty non nil parameter list for inline UDF caching

            build-team Couchbase Build Team added a comment - Build couchbase-server-7.1.2-3421 contains query commit a486b26 with commit message: MB-53420 consider empty non nil parameter list for inline UDF caching

            Build couchbase-server-8.0.0-1085 contains query commit a85b778 with commit message:
            MB-53420 consider empty non nil parameter list for inline UDF caching

            build-team Couchbase Build Team added a comment - Build couchbase-server-8.0.0-1085 contains query commit a85b778 with commit message: MB-53420 consider empty non nil parameter list for inline UDF caching

            verifeid in 7.1.2-3421, the query now runs in ~4s

            ajay.bhullar Ajay Bhullar added a comment - verifeid in 7.1.2-3421, the query now runs in ~4s

            Build couchbase-server-7.2.0-5000 contains query commit a486b26 with commit message:
            MB-53420 consider empty non nil parameter list for inline UDF caching

            build-team Couchbase Build Team added a comment - Build couchbase-server-7.2.0-5000 contains query commit a486b26 with commit message: MB-53420 consider empty non nil parameter list for inline UDF caching

            People

              ajay.bhullar Ajay Bhullar
              ajay.bhullar Ajay Bhullar
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty