we are using below query for getting data from Adobe, here tis queries run in loop for every segment which is mentioned as parameter. Please help how we can get data in better way
SELECT
sm.value.lastQualificationTime,
sm.value.status,
sm.key,
ds.segment,
ds.segment_name,
sm.email,
sm.region
FROM (
SELECT
EXPLODE(value),
email,
region
FROM (
SELECT
EXPLODE(Segmentmembership),
_lifetech.UnifiedContactProfile.emailAddress AS email,
_lifetech.UnifiedContactProfile.contactRegion AS region
FROM
profile_snapshot_export_dbd09966_53c4_
WHERE
_lifetech.UnifiedContactProfile.emailAddress IS NOT NULL
)
) sm
JOIN adwh_dim_segments ds
ON sm.key = ds.segment
WHERE
sm.key LIKE '%{segmentid}%'
AND sm.value.lastQualificationTime > '{lastQualificationTime}'
) dbtable1