vanstyn / RapidApp

Turnkey ajaxy webapps
http://rapi.io
Other
48 stars 15 forks source link

Improve handling of tables with very many rows (disable page count) #168

Closed timbunce closed 8 years ago

timbunce commented 8 years ago

One one of our tables, after a long wait, the UI generated by rdbic.pl shows Page 1 of 14,178,989. I don't need to know that, and I don't want to wait staring at a Loading message for that to be calculated, and others users don't want to be impacted by the db load either.

Do you have a mechanism to disable page counts? Could rdbic.pl make use of that to disable page counts for "large" tables?

vanstyn commented 8 years ago

@timbunce - I've just shipped 1.1100 to CPAN which adds support to grids to allow the user to turn total counts on or off, with full support for all the UI entanglements that entails.

Additionally, I've exposed an option in rdbic.pl to have the initial state of the total count option set to Off:

rdbic.pl --dsn dbi:... --total-counts-off

I kicked around the idea of have it decide automatically, but I couldn't come up with any good ways to determine "large" tables without adding more code that could get in the way (for instance, doing a simple count() on each table at startup could end up add a lot of time to startup). So for now it is just exposed as an option.

Let me know your thoughts and if this solution works for you

Thanks!

timbunce commented 8 years ago

Sounds good! I probably won't have time to try it for a while though.

A global option to set a default plus allowing a user to enable when wanted is a fine compromise. Thanks.

If you ever wanted to explore automating it then I'd suggesting adding a per-driver-type method called something like get_table_row_count_rough_estimate with a default method that just returns undef. Database where a count(*) is cheap could do that, others (like postgres) could get an estimate from the system catalogs.