CDM cache warming issues one record-count query per concept on Snowflake, Spark and BigQuery (getConceptsForBatch.sql relies on integer division)
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 66/100
調査の方向性
Start with getConceptsForBatch.sql and trace its use from CDMCacheService.warm into cacheRecordsBatch; the issue identifies the integer division expression that causes one group per concept on some platforms. Check how SqlRender handles the query for Snowflake, Spark/Databricks, and BigQuery, then verify warming batches concepts into ranges of 100,000 and reduces the number of getBatchConceptRecordCount queries.
索引モデルが issue の本文から書いたものです。
説明
Expected behavior
When the CDM record count cache is warmed for a source (CDMCacheService.warm), getConceptsForBatch.sql should split achilles_result_concept_count into ranges of 100,000 concepts (@batch_size), so that the warming job runs a handful of getBatchConceptRecordCount queries per source regardless of the database platform.
Actual behavior
The range id is computed as
select concept_id, ordinal / @batch_size as group_id
FROM (select concept_id, row_number() over (order by concept_id) as ordinal
FROM @resultTableQualifier.achilles_result_concept_count c) Q
and the outer query groups by group_id. This only yields whole ranges where / on two integers is integer division (PostgreSQL, SQL Server, Redshift). SqlRender does not rewrite the expression for any dialect, so:
- Snowflake:
ordinal / 100000is aNUMBERwith six decimals (1 / 100000 = 0.000010), distinct for every ordinal. - Spark / Databricks: the quotient is a
DOUBLE(1.0E-5), distinct for every ordinal. - BigQuery:
/onINT64returnsFLOAT64, distinct for every ordinal.
So on those platforms every concept is its own group, the query returns one min_concept = max_concept row per concept, and cacheRecordsBatch runs one getBatchConceptRecordCount query per row of achilles_result_concept_count (typically several hundred thousand round trips). The warming job for such a source takes hours to days instead of minutes and in practice never completes.
Steps to reproduce behavior
- Configure a Snowflake, Databricks/Spark or BigQuery source with a results daimon whose schema contains
achilles_result_concept_count(for example 300,000 rows) andis_cache_enabled = true. - Start WebAPI (or call
GET /cdmresults/clearCacheto trigger warming) and watch the query history on the database. - Observe
select group_id, min(concept_id) ..., max(concept_id) ... group by group_idreturning as many rows as the table has concepts, followed by oneselect cc.concept_id, record_count, descendant_record_count ... WHERE cc.concept_id >= ? and cc.concept_id <= ?per concept.
Directly on the platform:
-- Snowflake
select 1 / 100000; -- 0.000010
-- Spark
select 1 / 100000; -- 1.0E-5
-- BigQuery
select 1 / 100000; -- 1.0E-5
-- PostgreSQL / SQL Server
select 1 / 100000; -- 0
Environment
- WebAPI master @ 89de588 (also present in 2.15.x; the query dates from the Data Sources caching work in #1993)
- SqlRender 1.19.1
- 主要言語
- Java
- スター
- 153
- フォーク
- 186
- 平均マージ
- 2日 19時間
- マージ済み PR(30日)
- 19
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
OHDSI/WebAPI のほかの issue
-
Cohort sample with age "not between" includes people from other cohorts and ignores the gender filter対応中かも @DG47 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
GET /conceptset/{id}/expression returns items in nondeterministic order (query has no ORDER BY)オープン
難易度 3/5 1〜2日 初心者へのやさしさ 67/100
OHDSI/WebAPI#2543 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
OHDSI/WebAPI#2513 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
jakartaee/expression-language#501 ·
メンテナーはふだん 7 日以内に返信
-
enhancement triage
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
ShaftHQ/SHAFT_ENGINE#7902 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
Filter.toString() throws IllegalFormatConversionException for withinGeoRange filters対応中かも @dudanogueira が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
weaviate/java-client#638 ·