explain
select * from mdc2_mz_cost_view where patientid='60963' and clinicno='2307190246_102840' and hiscode='0';
不执行,执行计划不详细
explain (buffers true,analyze true,verbose true)
select * from mdc2_mz_cost_view where patientid='60963' and clinicno='2307190246_102840' and hiscode='0';
实际执行,并产生实际执行的执行计划
下面看看具体的:
# explain
select * from mdc2_mz_cost_view where patientid='60963' and clinicno='2307190246_102840' and hiscode='0';
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Unique (cost=1250110426.46..1250113863.96 rows=62500 width=701)
-> Sort (cost=1250110426.46..1250110582.71 rows=62500 width=701)
Sort Key: b."BalanceNo", pb."BillId", pb."BillNo", (CASE a."ChargesCategoryCode" WHEN '5'::text THEN )
-> Hash Left Join (cost=70268.47..1250086005.34 rows=62500 width=701)
Hash Cond: (o."相关ID" = o2."ID")
-> Hash Left Join (cost=50255.97..61039.72 rows=12500 width=732)
Hash Cond: (o."诊疗项目ID" = t."药名ID")
-> Hash Right Join (cost=30243.47..40583.47 rows=2500 width=694)
Hash Cond: ((cc."药品ID")::text = (o."收费细目ID")::text)
-> Foreign Scan on drug_dict cc (cost=10000.00..20000.00 rows=1000 width=238)
Oracle query: SELECT /*1760ee84eeafd92f*/ r10."药品ID", r10."产地" FROM "ZLHIS"."药品目录" r10
-> Hash (cost=20237.22..20237.22 rows=500 width=496)
-> Nested Loop (cost=10003.52..20237.22 rows=500 width=496)
-> Nested Loop (cost=1.27..218.71 rows=1 width=859)
-> Nested Loop (cost=0.85..218.11 rows=1 width=880)
-> Index Scan using processedbill_patid_idx on "ProcessedBill" pb (cost=0.42..209.65 rows=1 width=843)
Index Cond: ("PatId" = '60963'::text)
Filter: (("PatOriginCode" = '01'::text) AND ("OccurTime" > (now() + '-60 days'::interval))
-> Index Scan using balancebill_billid_idx on "BalanceBill" bb (cost=0.42..8.44 rows=1 width=74)
Index Cond: ("BillId" = pb."BillId")
-> Index Scan using "PK_Balanced" on "Balanced" b (cost=0.42..0.61 rows=1 width=53)
Index Cond: ("BalanceId" = bb."BalanceId")
Filter: ("BalanceStatusCode" = '1'::text)
-> Hash Join (cost=10002.25..20013.50 rows=500 width=376)
Hash Cond: ((o."ID")::text = a."OrderId")
-> Foreign Scan on orders o (cost=10000.00..20000.00 rows=1000 width=108)
Oracle query: SELECT /*5bdbf33d2da9cbf7*/ r7."ID", r7."相关ID", r7."序号", r7."诊疗类别" FROM "ZLHIS"."病人医嘱记录" r7
-> Hash (cost=1.00..1.00 rows=100 width=288)
-> Function Scan on json_to_recordset a (cost=0.00..1.00 rows=100 width=288)
Filter: ("OrderId" IS NOT NULL)
-> Hash (cost=20000.00..20000.00 rows=1000 width=78)
-> Foreign Scan on drug_characteristics t (cost=10000.00..20000.00 rows=1000 width=78)
Oracle query: SELECT /*69b41dd03b52e736*/ r8."药名ID", r8."药品剂型" FROM "ZLHIS"."药品特性" r8
-> Hash (cost=20000.00..20000.00 rows=1000 width=536)
-> Foreign Scan on orders o2 (cost=10000.00..20000.00 rows=1000 width=536)
Oracle query: SELECT /*5480e416df50af90*/ r12."ID", r12."医嘱内容" FROM "ZLHIS"."病人医嘱记录" r12
SubPlan 1
-> Foreign Scan on staff_dict t5 (cost=10000.00..20000.00 rows=1000 width=32)
Oracle query: SELECT /*c7dbdd5894bf799d*/ r1."ID", r1."编号" FROM "ZLHIS"."人员表" r1 WHERE (r1."ID" = to_number(:p1, 'fm999999'))
(39 rows)