-
Notifications
You must be signed in to change notification settings - Fork 8.3k
[Question] how to optimize funnels query? #1836
Copy link
Copy link
Closed
Description
hi, I need to use clickhouse to funnels query
info
- the table
trajectory_trackless_complexhas 2894082787 rows - pageid: 2538 --> 3242 --> 1682, ( homepage --> listpage --> detailpage )
query sql
SELECT
sum(step1_time != 0) AS home,
sum(step2_time != 0) AS list,
sum(step3_time != 0) AS detail
FROM
(
SELECT
loginkey,
groupArray(pageid) AS events,
groupArray(createtime) AS events_times,
arrayFilter((time, name) -> (name = 2538), events_times, events)[1] AS step1_time,
arrayFilter((time, name) -> ((name = 3242) AND (time >= step1_time) AND (step1_time != 0)), events_times, events)[1] AS step2_time,
arrayFilter((time, name) -> ((name = 1682) AND (time >= step2_time) AND (step2_time != 0)), events_times, events)[1] AS step3_time
FROM
(
SELECT
pageid,
createtime,
loginkey
FROM datacenter.trajectory_trackless_complex
WHERE pageid IN (2538, 3242, 1682)
ORDER BY createtime ASC
)
GROUP BY loginkey
)
Execute result
begining
after few seconds
it hungs
end
Question
how to optimize the query ?
how to make it run faster ?
thank you very match
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels

