• 
      

    Reduce queries on datagrids by pre-populating a cache of fetched objects.

    Review Request #3218 — Created July 15, 2012 and submitted

    Information

    Djblets
    release-0.6.x

    Reviewers

    Reduce queries on datagrids by pre-populating a cache of fetched objects.
    
    Many columns on the datagrid render related objects, such as a user. We
    had a cache in place that would prevent duplicate lookups of objects
    with the same ID, but we'd still do one query per unique ID.
    
    Now we allow columns to collect the data before rendering, based on the
    objects being displayed. By default, this will loop through the objects,
    build a list of all IDs that will be displayed, and then populate the
    existing cache with those fetched objects. This reduces the query count
    to at max one per column for all cases using ForeignKeys.
    
    ManyToManyFields is another matter entirely, and will take more
    specialized work.
    Tested this with all the datagrids on my copy of Review Board. Everything
    worked great. I verified through the list of SQL queries that we only
    had one per column that used a ForeignKey. ManyToManyFields still caused
    many more queries.
    
    Unit tests also passed.
    Description From Last Updated

    So, this will always return on the first obj in object_list, if the column isn't a pk column, and never …

    SM smacleod
    SM
    1. Looks good, just one little thing. Caching FTW.
    2. djblets/datagrid/grids.py (Diff revision 1)
       
       
       
       
       
      Show all issues
      So, this will always return on the first obj in object_list, if the column isn't a pk column, and never return when the column is a pk?
      
      If so, should this be checked before the loop somehow?
    3. 
        
    david
    1. Looks fine to me.
    2. 
        
    chipx86
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-0.6.x (2ca4550a)