Uploaded image for project: 'Fast Datapath Product'
  1. Fast Datapath Product
  2. FDP-359

[OVSDB] Don't iterate over all the rows on empty mutation requests

    • Icon: Story Story
    • Resolution: Done-Errata
    • Icon: Undefined Undefined
    • FDP-25.A
    • None
    • openvswitch3.4
    • None
    • False
    • Hide

      None

      Show
      None
    • False
    • rhel-9
    • None
    • rhel-net-ovs-dpdk
    • ssg_networking

      Consider a following database transaction:

      ovsdb-client transact '[
           "OVN_Southbound",
           {
              "op": "mutate",
              "table":"Logical_Flow",
              "where":[],
              "mutations":[]
          }
      ]'
      

      It is a mutation, but the list of mutations is empty and the condition where is also empty. Result of mutation is a number of affected rows. Since condition is empty, all the rows in the table are affected. But the list of mutations is empty, so they are not actually changed. Result:

      [{"count":5}]
      

      This is a simple trick that can mimic a SELECT COUNT(*) with OVSDB.
      The "op": "select" can not be used in this case, because the result of the selection is the list of rows, not their number. The closest we can get to the "COUNT" with "select" is by selecting all the rows and requesting only the uuid column and then count these IDs ourselves. That is more computationally heavy for both the server and the client.

      However, the mutation will still select all the rows before returning their count. It is not necessary if the condition is empty. So, it should be possible to shortcut this case and make it work faster by just returning the number of rows in the table (table.n) instead of re-counting them.

      We may also add a new operation "count" as an OVSDB extension and an alias that will do the same thing. Though it will not work on older database servers that do not have this extension, or for clients that only implement RFC7047. The mutation trick is backward compatible, even though will work a little sower on older servers.

              rh-ee-mpattric Mike Pattrick
              twilson@redhat.com Terry Wilson
              Hekai Wang Hekai Wang
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: