• Bruno Azzinnari's avatar
    Fix for a performance issue when getting the total row count when implementing... · 45a27235
    Bruno Azzinnari authored
    Fix for a performance issue when getting the total row count when implementing paging. When dealing with about 250.000 rows, it was taking about 30 secs to show one page on the first load. With this modifications it executes almost instantly.
    
    The problem was that the query applying .count() to the current query generated the SQL:
    
    SELECT count(*) AS count_1
    FROM ( SELECT ModelView-columns FROM ModelView-table WHERE conditions ) as anon_1;
    
    which made it actually get all the data in the inner query for then counting the rows and returning the amount. With this modification, the generated query is:
    
    SELECT count(*) AS count_1
    FROM ModelView-table
    WHERE conditions;
    
    that executes instantly.
    45a27235
Name
Last commit
Last update
..
contrib Loading commit data...
model Loading commit data...
static Loading commit data...
templates/admin Loading commit data...
tests Loading commit data...
translations Loading commit data...
__init__.py Loading commit data...
actions.py Loading commit data...
babel.py Loading commit data...
base.py Loading commit data...
form.py Loading commit data...
helpers.py Loading commit data...
tools.py Loading commit data...