CDM cache warming issues one record-count query per concept on Snowflake, Spark and BigQuery (getConceptsForBatch.sql relies on integer division)
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 66/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Java
- Star
- 153
- Fork
- 186
- Merge trung bình
- 2 ngày 19 giờ
- Pull request đã merge (30 ngày)
- 19
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của OHDSI/WebAPI
-
Cohort sample with age "not between" includes people from other cohorts and ignores the gender filterCó thể đã có người làm @DG47 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
GET /conceptset/{id}/expression returns items in nondeterministic order (query has no ORDER BY)Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 67/100
OHDSI/WebAPI#2543 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
OHDSI/WebAPI#2513 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
jakartaee/expression-language#501 ·
Maintainer thường phản hồi trong vòng 7 ngày
-
enhancement triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
ShaftHQ/SHAFT_ENGINE#7902 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
Filter.toString() throws IllegalFormatConversionException for withinGeoRange filtersCó thể đã có người làm @dudanogueira đã nhận hôm nay. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
weaviate/java-client#638 ·