MIT-LCP / MIT-LCP/mimic-code

Pls why did the import icustay_times fail?

Open
#1,837 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Jupyter Notebook
Stars
3.4k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

Prerequisites
Description

Description of the issue, including:

  • what you have tried
  • references to similar issues
  • queries demonstrating your question (if applicable)

I'm doing icustay_times.sql in a postgres database

\i icustay_times.sql
我在导入icustay_times.sql时出现一个报错
[SQL] Query icustay_times start
[ERR] 错误: 由于语句执行超时,正在取消查询命令

-- THIS SCRIPT IS AUTOMATICALLY GENERATED. DO NOT EDIT IT DIRECTLY.
DROP TABLE IF EXISTS icustay_times; CREATE TABLE icustay_times AS
-- create a table which has fuzzy boundaries on hospital admission
-- involves first creating a lag/lead version of disch/admit time
-- get first/last heart rate measurement during hospitalization for each stay_id
WITH t1 AS (
SELECT ce.stay_id
, MIN(charttime) AS intime_hr
, MAX(charttime) AS outtime_hr
FROM mimiciv_icu.chartevents ce
-- only look at heart rate
WHERE ce.itemid = 220045
GROUP BY ce.stay_id
)

-- add in subject_id/hadm_id
SELECT
ie.subject_id, ie.hadm_id, ie.stay_id
, t1.intime_hr
, t1.outtime_hr
FROM mimiciv_icu.icustays ie
LEFT JOIN t1
ON ie.stay_id = t1.stay_id;

经过分析是group by导致查询过慢,请问该如何优化或者怎么样做才能导入成功
After analysis, the execution is too slow due to group by, how to optimize or how to import successfully?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with icustay_times.sql and the PostgreSQL statement shown in the issue, focusing on the GROUP BY over mimiciv_icu.chartevents and the reported statement timeout. Reproduce the import in PostgreSQL and inspect the query's execution behavior; done means the script completes successfully without timing out.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql
Domain
databases, performance
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.