

# Configure the extension

Extension settings become available after you load the extension. To change a setting before you run `ATTACH`, first run `LOAD athena FROM aws.amazon.com;`.

Use `SET` to change a setting for the session, and `RESET` to restore its default. A setting that is read at `ATTACH` applies to catalogs that you attach afterward.

```sql
SET {{setting}} = {{value}};
RESET {{setting}};
```

## Requests and query execution
<a name="connect-with-duckdb-extension-settings-requests"></a>

The following table lists settings for requests and query execution.



| Setting | Default | Behavior | 
| --- | --- | --- | 
| athena\_endpoint | Region public endpoint | Athena endpoint override; read at ATTACH. | 
| athena\_glue\_endpoint | Region public endpoint | Glue endpoint for listing table buckets with S3Tables '\*'. | 
| athena\_workgroup | primary | Workgroup when the ATTACH path does not name one. | 
| athena\_engine\_version | Not set | Engine named on submissions when ATTACH did not pin an engine; leave unset for the workgroup-based setup. | 
| athena\_poll\_ms | 200 | Maximum polling wait, in milliseconds, during the first five seconds. 0 uses the default of 200; values above 60000 are treated as 60000. Later waits grow to the larger of this effective value and 2,000 milliseconds. | 
| athena\_timeout\_seconds | 900 | Seconds an execution can remain unfinished before the extension sends a stop request. 0 uses the default of 900; values above 31536000 are treated as 31536000. If the execution completed before the stop took effect, the statement preserves its final state. | 
| athena\_log\_http | false | Log Athena and Glue requests to the DuckDB HTTP log; excludes result stream reads. | 

## Metadata
<a name="connect-with-duckdb-extension-settings-metadata"></a>

The following table lists metadata settings.



| Setting | Default | Behavior | 
| --- | --- | --- | 
| athena\_lazy\_schema\_listing | true | Defer database listing until needed; read at ATTACH. Catalogs with S3Tables list at ATTACH. | 
| athena\_single\_table\_lookup | true | Look up a named table individually until the database is listed; read at ATTACH. | 
| athena\_metadata\_cache\_scope | transaction | Refresh metadata each transaction, or set connection to retain it until rollback, a write or DDL submitted through the attached catalog or athena\_execute, or CALL athena\_clear\_cache(). Writes through athena\_query do not clear this cache. Changes apply from the next transaction. | 
| athena\_metadata\_concurrency | 2 | Concurrent database reads for catalog-wide listing until throttled; 1 reads sequentially. | 

Metadata calls share the account Athena throttling rate across clients.

With `athena_metadata_cache_scope = 'connection'`, cached metadata can remain stale after other clients change tables or databases. Call `athena_clear_cache()` to refresh the next lookup in the attached catalogs. Use the following commands to refresh cached table listings after another client changes the database.

```sql
SET athena_metadata_cache_scope = 'connection';
SELECT table_name FROM information_schema.tables
WHERE table_catalog = 'ath' AND table_schema = '{{my_database}}';
CALL athena_clear_cache();
SELECT table_name FROM information_schema.tables
WHERE table_catalog = 'ath' AND table_schema = '{{my_database}}';
RESET athena_metadata_cache_scope;
```

## Result retrieval
<a name="connect-with-duckdb-extension-settings-results"></a>

The following table lists result retrieval settings.



| Setting | Default | Behavior | 
| --- | --- | --- | 
| athena\_fetch\_size | 0 (10,000 rows) | Target rows per ranged S3 comma-separated values (CSV) read; maximum 1,000,000. | 
| athena\_decode\_threads | 4 | Threads that decode Arrow result batches in parallel. 1 decodes on the query thread; the maximum is 64. | 
| athena\_stream\_buffer\_bytes | 8388608 | Per-stream decode buffer budget, with a minimum of 65536 bytes. It accounts for framed data awaiting decoding and decoded batches awaiting delivery. A whole message can exceed the budget. It does not cap the separate HTTP queue or total process memory. | 
| athena\_schema\_cache\_entries | 100 | Statement shapes whose result schemas the connection retains. | 
| athena\_max\_fragment\_bytes | 68719476736 | Maximum bytes per streamed result; 0 removes the cap. | 
| athena\_stream\_stall\_seconds | 300 | Seconds without source progress during an active wait for data or for the response to end before the stream is abandoned; time blocked by backpressure is excluded. 0 removes the guard. | 

## Query pushdown
<a name="connect-with-duckdb-extension-settings-pushdown"></a>

The following table lists pushdown settings.



| Setting | Default | Behavior | 
| --- | --- | --- | 
| athena\_enable\_remote\_pushdown | true | Push eligible statements to Athena; read at ATTACH. When false, reads run locally over per-table reads. Writes and data definition language (DDL) statements still run on Athena unless they contain a query, other than a view body, that is neither a VALUES list nor a SELECT without FROM. | 
| athena\_enable\_filter\_pushdown | true | Include eligible local plan filters in per-table reads; other filters are applied locally. | 

## Inspect per-table reads
<a name="connect-with-duckdb-extension-settings-pushdown-example"></a>

Set `athena_enable_remote_pushdown` before attaching the catalog to keep its queries local over per-table reads. Then set `athena_enable_filter_pushdown` to `false` to inspect a read without the local plan filter in the SQL sent to Athena. The following example logs a read of a table with `product` and `units` columns.

```sql
SET athena_enable_remote_pushdown = false;
ATTACH 'athena://{{us-west-2}}/{{my-duckdb-workgroup}}' AS local_reads
    (TYPE athena, Catalog 's3tablescatalog/{{amzn-s3-demo-table-bucket}}',
     Database '{{retail}}', Secret 'athena_creds');
RESET athena_enable_remote_pushdown;
SET athena_enable_filter_pushdown = false;
CALL enable_logging('athena', storage := 'memory');
SELECT product FROM local_reads.{{retail}}.{{widget_sales}}
WHERE units > 50 ORDER BY product;
SELECT message FROM duckdb_logs WHERE message LIKE '%table scan streamed%' OR message LIKE '%table scan as csv%';
RESET athena_enable_filter_pushdown;
DETACH local_reads;
CALL disable_logging();
```