From 34bc16aa591a2f02b2bb33277d33e5bccfb95569 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Fri, 28 Feb 2020 16:19:23 -0800 Subject: [PATCH 1/2] Only attempt counts for databases < 100MB --- datasette/views/index.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/datasette/views/index.py b/datasette/views/index.py index f2e5f774..fe88a38c 100644 --- a/datasette/views/index.py +++ b/datasette/views/index.py @@ -11,8 +11,8 @@ from .base import BaseView # Truncate table list on homepage at: TRUNCATE_AT = 5 -# Only attempt counts if less than this many tables: -COUNT_TABLE_LIMIT = 30 +# Only attempt counts if database less than this size in bytes: +COUNT_DB_SIZE_LIMIT = 100 * 1024 * 1024 class IndexView(BaseView): @@ -29,7 +29,7 @@ class IndexView(BaseView): views = await db.view_names() # Perform counts only for immutable or DBS with <= COUNT_TABLE_LIMIT tables table_counts = {} - if not db.is_mutable or len(table_names) <= COUNT_TABLE_LIMIT: + if not db.is_mutable or db.size < COUNT_DB_SIZE_LIMIT: table_counts = await db.table_counts(10) # If any of these are None it means at least one timed out - ignore them all if any(v is None for v in table_counts.values()): From 025fdd46f77822c0cbeb7856611c0a65a9b83057 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Fri, 28 Feb 2020 16:19:41 -0800 Subject: [PATCH 2/2] Applied black --- tests/fixtures.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fixtures.py b/tests/fixtures.py index 644de906..0c1b10a0 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -229,7 +229,7 @@ def app_client_with_cors(): @pytest.fixture(scope="session") def app_client_immutable_and_inspect_file(): - inspect_data = {'fixtures': {'tables': {'sortable': {'count': 100}}}} + inspect_data = {"fixtures": {"tables": {"sortable": {"count": 100}}}} yield from make_app_client(is_immutable=True, inspect_data=inspect_data)