> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-fix-nav-issues.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# DataStore configuration

> Configure DataStore execution engine, logging, caching, and profiling

DataStore provides comprehensive configuration options for execution engine selection, compatibility mode, logging, caching, profiling, and dtype correction.

<h2 id="quick-reference">
  Quick Reference
</h2>

```python theme={null}
from chdb.datastore.config import config

# Quick setup presets
config.enable_debug()           # Enable verbose logging
config.use_chdb()               # Force ClickHouse engine
config.use_pandas()             # Force pandas engine
config.use_auto()               # Auto-select engine (default)
config.use_performance_mode()   # SQL-first, max throughput
config.use_pandas_compat()      # Full pandas compatibility (default)
config.enable_profiling()       # Enable performance profiling
```

<h2 id="all-options">
  All Configuration Options
</h2>

| Category      | Option                   | Values                        | Default  | Description                                  |
| ------------- | ------------------------ | ----------------------------- | -------- | -------------------------------------------- |
| **Logging**   | `log_level`              | DEBUG/INFO/WARNING/ERROR      | WARNING  | Log verbosity                                |
|               | `log_format`             | "simple", "verbose"           | "simple" | Log message format                           |
| **Cache**     | `cache_enabled`          | True/False                    | True     | Enable result caching                        |
|               | `cache_ttl`              | float (seconds)               | 0.0      | Cache time-to-live                           |
| **Engine**    | `execution_engine`       | "auto", "chdb", "pandas"      | "auto"   | Execution engine                             |
|               | `cross_datastore_engine` | "auto", "chdb", "pandas"      | "auto"   | Cross-DataStore operations                   |
| **Compat**    | `compat_mode`            | "pandas", "performance"       | "pandas" | Pandas compatibility vs SQL-first throughput |
| **Profiling** | `profiling_enabled`      | True/False                    | False    | Enable profiling                             |
| **Dtype**     | `correction_level`       | NONE/CRITICAL/HIGH/MEDIUM/ALL | HIGH     | Dtype correction level                       |

***

<h2 id="methods">
  Configuration Methods
</h2>

<h3 id="logging">
  Logging Configuration
</h3>

```python theme={null}
from chdb.datastore.config import config
import logging

# Set log level
config.set_log_level(logging.DEBUG)
config.set_log_level(logging.INFO)
config.set_log_level(logging.WARNING)  # Default
config.set_log_level(logging.ERROR)

# Set log format
config.set_log_format("simple")   # Default
config.set_log_format("verbose")  # More details

# Quick enable debug mode
config.enable_debug()  # Sets DEBUG level + verbose format
```

See [Logging](/products/chdb/debugging/logging) for details.

<h3 id="cache">
  Cache Configuration
</h3>

```python theme={null}
# Enable/disable caching
config.set_cache_enabled(True)   # Default
config.set_cache_enabled(False)  # Disable caching

# Set cache TTL (time-to-live)
config.set_cache_ttl(60.0)  # Cache expires after 60 seconds
config.set_cache_ttl(0.0)   # No expiration (default)

# Check current settings
print(config.cache_enabled)
print(config.cache_ttl)
```

<h3 id="engine">
  Engine Configuration
</h3>

```python theme={null}
# Set execution engine
config.set_execution_engine('auto')    # Auto-select (default)
config.set_execution_engine('chdb')    # Force ClickHouse
config.set_execution_engine('pandas')  # Force pandas

# Quick presets
config.use_auto()     # Auto-select
config.use_chdb()     # Force ClickHouse
config.use_pandas()   # Force pandas

# Cross-DataStore engine (for operations between different DataStores)
config.set_cross_datastore_engine('auto')
config.set_cross_datastore_engine('chdb')
config.set_cross_datastore_engine('pandas')

# Check current engine
print(config.execution_engine)
```

See [Execution Engine](/products/chdb/configuration/execution-engine) for details.

<h3 id="compat-mode">
  Compatibility Mode
</h3>

```python theme={null}
# Performance mode: SQL-first, no pandas compatibility overhead
config.use_performance_mode()
# or: config.set_compat_mode('performance')

# Pandas compatibility mode (default)
config.use_pandas_compat()
# or: config.set_compat_mode('pandas')

# Check current mode
print(config.compat_mode)  # 'pandas' or 'performance'
```

See [Performance Mode](/products/chdb/configuration/performance-mode) for details.

<h3 id="profiling">
  Profiling Configuration
</h3>

```python theme={null}
# Enable profiling
config.enable_profiling()
config.set_profiling_enabled(True)

# Disable profiling
config.set_profiling_enabled(False)

# Check if profiling is enabled
print(config.profiling_enabled)
```

See [Profiling](/products/chdb/debugging/profiling) for details.

<h3 id="dtype">
  Dtype Correction
</h3>

```python theme={null}
from chdb.datastore.dtype_correction.config import CorrectionLevel

# Set correction level
config.set_correction_level(CorrectionLevel.NONE)      # No correction
config.set_correction_level(CorrectionLevel.CRITICAL)  # Critical types only
config.set_correction_level(CorrectionLevel.HIGH)      # Default
config.set_correction_level(CorrectionLevel.MEDIUM)    # More corrections
config.set_correction_level(CorrectionLevel.ALL)       # All corrections
```

***

<h2 id="config-object">
  Using config Object
</h2>

The `config` object is a singleton that manages all settings:

```python theme={null}
from chdb.datastore.config import config

# Read settings
print(config.log_level)
print(config.execution_engine)
print(config.cache_enabled)
print(config.profiling_enabled)

# Modify settings
config.set_log_level(logging.DEBUG)
config.set_execution_engine('chdb')
config.set_cache_enabled(False)
config.enable_profiling()
```

***

<h2 id="in-code">
  Configuration in Code
</h2>

<h3 id="per-script">
  Per-Script Configuration
</h3>

```python theme={null}
from chdb import datastore as pd
from chdb.datastore.config import config

# Configure at script start
config.enable_debug()
config.use_chdb()
config.enable_profiling()

# Your DataStore code
ds = pd.read_csv("data.csv")
result = ds.filter(ds['age'] > 25).groupby('city').agg({'salary': 'mean'})
```

<h3 id="context-manager">
  Context Manager (Future)
</h3>

```python theme={null}
# Planned feature: temporary configuration
with config.override(execution_engine='pandas'):
    result = ds.process()
# Original settings restored
```

***

<h2 id="scenarios">
  Common Configuration Scenarios
</h2>

<h3 id="dev-config">
  Development/Debugging
</h3>

```python theme={null}
from chdb.datastore.config import config

config.enable_debug()        # Verbose logging
config.enable_profiling()    # Performance tracking
config.set_cache_enabled(False)  # Disable caching for fresh results
```

<h3 id="prod-config">
  Production
</h3>

```python theme={null}
from chdb.datastore.config import config
import logging

config.set_log_level(logging.WARNING)  # Minimal logging
config.set_execution_engine('auto')    # Optimal engine selection
config.set_cache_enabled(True)         # Enable caching
config.set_profiling_enabled(False)    # Disable profiling overhead
```

<h3 id="max-throughput-config">
  Maximum Throughput
</h3>

```python theme={null}
from chdb.datastore.config import config

config.use_performance_mode()    # SQL-first, no pandas overhead
config.set_cache_enabled(False)  # Disable cache for streaming
```

<h3 id="perf-config">
  Performance Testing
</h3>

```python theme={null}
from chdb.datastore.config import config

config.use_chdb()            # Force ClickHouse for benchmarks
config.enable_profiling()    # Track performance
config.set_cache_enabled(False)  # Disable cache for accurate timing
```

<h3 id="compat-config">
  Pandas Compatibility Testing
</h3>

```python theme={null}
from chdb.datastore.config import config

config.use_pandas()          # Force pandas engine
config.enable_debug()        # See what operations are used
```

***

<h2 id="related">
  Related Documentation
</h2>

* [Execution Engine](/products/chdb/configuration/execution-engine) - Engine selection details
* [Performance Mode](/products/chdb/configuration/performance-mode) - SQL-first mode for maximum throughput
* [Function Config](/products/chdb/configuration/function-config) - Per-function engine configuration
* [Logging](/products/chdb/debugging/logging) - Logging configuration
* [Profiling](/products/chdb/debugging/profiling) - Performance profiling
