メインコンテンツへスキップ
DataStore では、実行エンジンの選択、互換性モード、ログ、キャッシュ、プロファイリング、dtype 補正について包括的に設定できます。

クイックリファレンス

from chdb.datastore.config import config

# クイックセットアッププリセット
config.enable_debug()           # 詳細ログを有効化
config.use_chdb()               # ClickHouse engineを強制使用
config.use_pandas()             # pandas engineを強制使用
config.use_auto()               # engineを自動選択(デフォルト)
config.use_performance_mode()   # SQL優先、最大throughput
config.use_pandas_compat()      # pandas完全互換(デフォルト)
config.enable_profiling()       # パフォーマンスプロファイリングを有効化

すべての設定オプション

カテゴリオプションデフォルト説明
ログlog_levelDEBUG/INFO/WARNING/ERRORWARNINGログの詳細度
log_format”simple”, “verbose""simple”ログメッセージのフォーマット
キャッシュcache_enabledTrue/FalseTrue結果のキャッシュを有効化
cache_ttlfloat (Seconds)0.0cache の有効期限 (TTL)
エンジンexecution_engine”auto”, “chdb”, “pandas""auto”実行エンジン
cross_datastore_engine”auto”, “chdb”, “pandas""auto”DataStore をまたぐ操作
互換性compat_mode”pandas”, “performance""pandas”pandas 互換性と SQL 優先のスループットのどちらを重視するか
プロファイリングprofiling_enabledTrue/FalseFalseプロファイリングを有効化
Dtypecorrection_levelNONE/CRITICAL/HIGH/MEDIUM/ALLHIGHDtype の補正レベル

設定方法

ログ設定

from chdb.datastore.config import config
import logging

# ログレベルを設定する
config.set_log_level(logging.DEBUG)
config.set_log_level(logging.INFO)
config.set_log_level(logging.WARNING)  # デフォルト
config.set_log_level(logging.ERROR)

# ログフォーマットを設定する
config.set_log_format("simple")   # デフォルト
config.set_log_format("verbose")  # 詳細情報

# デバッグモードを即座に有効にする
config.enable_debug()  # DEBUGレベル + verboseフォーマットを設定する
詳細については、ログを参照してください。

Cache の設定

# キャッシュの有効化/無効化
config.set_cache_enabled(True)   # デフォルト
config.set_cache_enabled(False)  # キャッシュを無効化

# cache の有効期限 (TTL) を設定
config.set_cache_ttl(60.0)  # 60秒後にcacheが期限切れになる
config.set_cache_ttl(0.0)   # 期限切れなし(デフォルト)

# 現在の設定を確認
print(config.cache_enabled)
print(config.cache_ttl)

エンジン設定

# 実行エンジンを設定する
config.set_execution_engine('auto')    # 自動選択(デフォルト)
config.set_execution_engine('chdb')    # ClickHouse を強制使用
config.set_execution_engine('pandas')  # pandas を強制使用

# クイックプリセット
config.use_auto()     # 自動選択
config.use_chdb()     # ClickHouse を強制使用
config.use_pandas()   # pandas を強制使用

# クロス DataStore エンジン(異なる DataStore 間の操作用)
config.set_cross_datastore_engine('auto')
config.set_cross_datastore_engine('chdb')
config.set_cross_datastore_engine('pandas')

# 現在のエンジンを確認する
print(config.execution_engine)
詳細については、実行エンジンを参照してください。

互換性モード

# パフォーマンスモード: SQL優先、pandasの互換性オーバーヘッドなし
config.use_performance_mode()
# または: config.set_compat_mode('performance')

# Pandas互換性モード(デフォルト)
config.use_pandas_compat()
# または: config.set_compat_mode('pandas')

# 現在のモードを確認
print(config.compat_mode)  # 'pandas' または 'performance'
詳細は、パフォーマンスモードを参照してください。

プロファイリングの設定

# プロファイリングを有効にする
config.enable_profiling()
config.set_profiling_enabled(True)

# プロファイリングを無効にする
config.set_profiling_enabled(False)

# プロファイリングが有効かどうかを確認する
print(config.profiling_enabled)
詳細については、プロファイリングを参照してください。

dtype の修正

from chdb.datastore.dtype_correction.config import CorrectionLevel

# 補正レベルを設定する
config.set_correction_level(CorrectionLevel.NONE)      # 補正なし
config.set_correction_level(CorrectionLevel.CRITICAL)  # クリティカルな型のみ
config.set_correction_level(CorrectionLevel.HIGH)      # デフォルト
config.set_correction_level(CorrectionLevel.MEDIUM)    # より多くの補正
config.set_correction_level(CorrectionLevel.ALL)       # すべての補正

configオブジェクトの使用

config オブジェクトは、すべての設定を管理するシングルトンです。
from chdb.datastore.config import config

# 設定を読み取る
print(config.log_level)
print(config.execution_engine)
print(config.cache_enabled)
print(config.profiling_enabled)

# 設定を変更する
config.set_log_level(logging.DEBUG)
config.set_execution_engine('chdb')
config.set_cache_enabled(False)
config.enable_profiling()

コード内での設定

スクリプト単位の設定

from chdb import datastore as pd
from chdb.datastore.config import config

# スクリプトの開始時に設定する
config.enable_debug()
config.use_chdb()
config.enable_profiling()

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

コンテキストマネージャー (今後対応予定)

# 計画中の機能: 一時的な設定
with config.override(execution_engine='pandas'):
    result = ds.process()
# 元の設定に復元

よくある設定パターン

開発/デバッグ

from chdb.datastore.config import config

config.enable_debug()        # 詳細ログ
config.enable_profiling()    # パフォーマンス計測
config.set_cache_enabled(False)  # 最新の結果を得るためにキャッシュを無効化

本番環境

from chdb.datastore.config import config
import logging

config.set_log_level(logging.WARNING)  # 最小限のログ
config.set_execution_engine('auto')    # 最適なエンジン選択
config.set_cache_enabled(True)         # キャッシュを有効化
config.set_profiling_enabled(False)    # プロファイリングのオーバーヘッドを無効化

最大スループット

from chdb.datastore.config import config

config.use_performance_mode()    # SQLファースト、pandasのオーバーヘッドなし
config.set_cache_enabled(False)  # ストリーミング用にcacheを無効化

性能テスト

from chdb.datastore.config import config

config.use_chdb()            # ベンチマーク用にClickHouseを強制使用
config.enable_profiling()    # パフォーマンスを計測
config.set_cache_enabled(False)  # 正確な計測のためcacheを無効化

Pandas 互換性テスト

from chdb.datastore.config import config

config.use_pandas()          # pandasエンジンを強制使用
config.enable_debug()        # 使用される操作を確認

最終更新日 2026年6月10日