Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions docs/pages/product/apis-integrations/queries.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,17 @@ from default ordering by passing an empty array (`[]`) object as `order`.

### Row limit

By default, [any query](#query-types) will return no more than 10,000 rows
in the result set. It serves as a safeguard against data scraping and
denial-of-service (DoS) attacks if Cube is exposed to untrusted environments.
By default, [any query](#query-types) that does not explicitly specify the row
limit, will return no more than 10,000 rows in the result set. You can use the
`CUBEJS_DB_QUERY_DEFAULT_LIMIT` environment variable to override it. This serves
as a safeguard against data scraping and denial-of-service (DoS) attacks if Cube
is exposed to untrusted environments.

The maximum allowed limit is 50,000 rows. You can use the `CUBEJS_DB_QUERY_LIMIT`
environment variable to override it. You can also implement
[pagination][ref-pagination-recipe] to fetch more rows than the maximum limit.
Finally, if you're using the [SQL API][ref-sql-api], you can enable the
[streaming mode][ref-sql-api-streaming] to ignore the maximum row limit.

### Time zone

Expand Down Expand Up @@ -394,3 +398,4 @@ Additionally, note that ungrouped queries have additional requirements for
[ref-query-rewrite]: /reference/configuration/config#query_rewrite
[ref-ref-sql-api]: /reference/sql-api
[blog-compare-date-range]: https://cube.dev/blog/comparing-data-over-different-time-periods
[ref-sql-api-streaming]: /product/apis-integrations/sql-api#streaming
15 changes: 14 additions & 1 deletion docs/pages/product/apis-integrations/sql-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,18 @@ error: `Error during rewrite: Can't find rewrite due to 10002 AST node limit rea
Use the following environment variables to allocate more resources for query planning:
`CUBESQL_REWRITE_MAX_NODES`, `CUBESQL_REWRITE_MAX_ITERATIONS`, `CUBESQL_REWRITE_TIMEOUT`.

## Streaming

By default, query results are loaded in a single batch. However, a more effective
*streaming mode* can be used for large result sets. To enable it, set the
`CUBESQL_STREAM_MODE` environment variable to `true`.

<InfoBox>

When the streaming mode is enabled, the maximum [row limit][ref-queries-row-limit]
does not apply to SQL API queries. They can return an unlimited number of rows.

</InfoBox>

[ref-sql-api-auth]: /product/apis-integrations/sql-api/security
[ref-config-checksqlauth]: /reference/configuration/config#checksqlauth
Expand Down Expand Up @@ -241,4 +253,5 @@ Use the following environment variables to allocate more resources for query pla
[link-postgres-information-schema]: https://www.postgresql.org/docs/16/information-schema.html
[link-postgres-backslash-commands]: https://www.postgresql.org/docs/current/app-psql.html#APP-PSQL-META-COMMANDS
[postgres-protocol]: https://www.postgresql.org/docs/current/protocol.html
[cube-bi-use-case]: https://cube.dev/use-cases/connected-bi
[cube-bi-use-case]: https://cube.dev/use-cases/connected-bi
[ref-queries-row-limit]: /product/apis-integrations/queries#row-limit
9 changes: 9 additions & 0 deletions docs/pages/reference/configuration/environment-variables.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,15 @@ The username used to connect to the database.
| ------------------------- | ---------------------- | --------------------- |
| A valid database username | N/A | N/A |

## `CUBEJS_DB_QUERY_DEFAULT_LIMIT`

The default [row limit][ref-row-limit] in the result set if it's not explicitly
specified in an API query.

| Possible Values | Default in Development | Default in Production |
| ------------------------- | ---------------------- | --------------------- |
| A positive integer number | `10000` | `10000` |

## `CUBEJS_DB_QUERY_LIMIT`

The maximum [row limit][ref-row-limit] in the result set.
Expand Down