Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

?_nocount=1 for opting out of table counts #1353

Closed
simonw opened this issue Jun 1, 2021 · 2 comments
Closed

?_nocount=1 for opting out of table counts #1353

simonw opened this issue Jun 1, 2021 · 2 comments

Comments

@simonw
Copy link
Owner

simonw commented Jun 1, 2021

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:

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:

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:

@simonw
Copy link
Owner Author

simonw commented Jun 1, 2021

I'm going to rename ?_nofacets=1 to ?_nofacet=1 to keep it consistent with the new ?_nocount=1 option (and because I don't like ?_nocounts=1).

@simonw
Copy link
Owner Author

simonw commented Jun 1, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant