• 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
babel Loading commit data...
doc Loading commit data...
examples Loading commit data...
flask_admin Loading commit data...
.gitignore Loading commit data...
.gitmodules Loading commit data...
.travis.yml Loading commit data...
AUTHORS Loading commit data...
LICENSE Loading commit data...
MANIFEST.in Loading commit data...
Makefile Loading commit data...
NOTICE Loading commit data...
README.rst Loading commit data...
TODO.txt Loading commit data...
requirements.txt Loading commit data...
setup.cfg Loading commit data...
setup.py Loading commit data...