Uploaded image for project: 'Data Management'
  1. Data Management
  2. DM-10247

Optimize access to SQuaSH REST API

    Details

    • Type: Story
    • Status: Done
    • Resolution: Done
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Templates:
    • Story Points:
      2.8
    • Team:
      SQuaRE

      Description

      When using nested serializers in DRF the queries involving multiple tables can be improved using the prefetch_related() method from the Django QuerySet API which automatically retrieve related objects in single batch.

      https://docs.djangoproject.com/en/1.11/ref/models/querysets/#prefetch-related

      Also drf-extensions package can be used to enable cache in SQUASH REST API at the view level.

      http://chibisov.github.io/drf-extensions/docs/#cacheresponsemixin

      A useful tool to monitor the queries that are executed when accessing the API endpoints is the Django debug toolbar:

      https://django-debug-toolbar.readthedocs.io/en/stable/

        Attachments

        1. cache1.png
          cache1.png
          279 kB
        2. cache2.png
          cache2.png
          212 kB
        3. prefetch1.png
          prefetch1.png
          565 kB
        4. prefetch2.png
          prefetch2.png
          380 kB
        5. prefetch3.png
          prefetch3.png
          541 kB

          Issue Links

            Activity

              People

              • Assignee:
                afausti Angelo Fausti
                Reporter:
                afausti Angelo Fausti
                Reviewers:
                Joshua Hoblitt
                Watchers:
                Angelo Fausti, Frossie Economou, Joshua Hoblitt
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Summary Panel