在具有JOIN的Siddhi查询中,最好将条件条件放在ON子句或过滤条件中。
JOIN ON子句中的条件
FROM Stroke_TPA_Ingest_Ras_eMar_Output_Stream as Tpa
JOIN PreAdmitADTTable as Adt
ON str:concat(Tpa.FacilityMnemonic,"-",Tpa.AccountNumber) == str:concat(Adt.FacilityMnemonic,"-",Adt.AccountNumber)
AND (
(
(str:contains(Tpa.TpaPharmacyCodesValueSet, "https://fhir.app.medcity.net/ValueSet/StrokeTpaPharmacyCodes|"))
AND
(convert(Tpa.AdministrationDosageFormId, 'int') > 40 AND convert(Tpa.AdministrationDosageFormId, 'int') <= 90)
)
OR
(
(str:contains(Tpa.TpaPharmacyCodesValueSet, "https://fhir.app.medcity.net/ValueSet/StrokeTpaBolusPharmacyCodes|"))
AND
(convert(Tpa.AdministrationDosageFormId, 'int') > 0 AND convert(Tpa.AdministrationDosageFormId, 'int') <= 9)
)
)
SELECT Tpa.meta_LinkId as meta_LinkId
INSERT INTO AlertStreamIntermediary;
过滤器中的条件
FROM Stroke_TPA_Ingest_Ras_eMar_Output_Stream[
((str:contains(Tpa.TpaPharmacyCodesValueSet, "https://fhir.app.medcity.net/ValueSet/StrokeTpaPharmacyCodes|"))
AND
(convert(Tpa.AdministrationDosageFormId, 'int') > 40 AND convert(Tpa.AdministrationDosageFormId, 'int') <= 90))
OR
((str:contains(Tpa.TpaPharmacyCodesValueSet, "https://fhir.app.medcity.net/ValueSet/StrokeTpaBolusPharmacyCodes|"))
AND
(convert(Tpa.AdministrationDosageFormId, 'int') > 0 AND convert(Tpa.AdministrationDosageFormId, 'int') <= 9))
] as Tpa
JOIN PreAdmitADTTable as Adt
ON str:concat(Tpa.FacilityMnemonic,"-",Tpa.AccountNumber) == str:concat(Adt.FacilityMnemonic,"-",Adt.AccountNumber)
SELECT Tpa.meta_LinkId as meta_LinkId
INSERT INTO AlertStreamIntermediary;
这两个查询似乎是等效的,但是想知道是否存在性能差异
答案 0 :(得分:0)
第二个查询的性能会更好,因为当事件到达连接查询时,我们已经使用过滤器查询消除了不需要的事件。由于Siddhi用作管道,与过滤器不匹配的事件将被丢弃在该层。有关Siddhi体系结构的更多信息,您可以参考this。