-
-
Notifications
You must be signed in to change notification settings - Fork 771
Closed
Labels
Description
Running a trace against a CSV streaming export with the new _trace=1
feature from #1351 shows that the following code is executing a select count(*) from table
for every page of results returned:
datasette/datasette/views/table.py
Lines 700 to 705 in d1d06ac
if count_sql and filtered_table_rows_count is None: | |
try: | |
count_rows = list(await db.execute(count_sql, from_sql_params)) | |
filtered_table_rows_count = count_rows[0][0] | |
except QueryInterrupted: | |
pass |
This is inefficient - a new ?_nocount=1
option would let us disable this count in the same way as #1349:
datasette/datasette/views/base.py
Lines 264 to 276 in d1d06ac
async def as_csv(self, request, database, hash, **kwargs): | |
stream = request.args.get("_stream") | |
# Do not calculate facets: | |
if not request.args.get("_nofacets"): | |
if not request.query_string: | |
new_query_string = "_nofacets=1" | |
else: | |
new_query_string = request.query_string + "&_nofacets=1" | |
new_scope = dict( | |
request.scope, query_string=new_query_string.encode("latin-1") | |
) | |
request.scope = new_scope | |
if stream: |