Skip to content

Commit

Permalink
limit event/session table to 1000 for performance
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscao633 committed Aug 13, 2024
1 parent 7ae53e2 commit 3805a0b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/queries/analytics/events/getWebsiteEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ async function clickhouseQuery(websiteId: string, filters: QueryFilters, pagePar

return pagedQuery(
`
with events as (
select
event_id as id,
website_id as websiteId,
Expand All @@ -56,6 +57,8 @@ async function clickhouseQuery(websiteId: string, filters: QueryFilters, pagePar
: ''
}
order by created_at desc
limit 1000)
select * from events
`,
{ ...params, query },
pageParams,
Expand Down
3 changes: 3 additions & 0 deletions src/queries/analytics/sessions/getWebsiteSessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ async function clickhouseQuery(websiteId: string, filters: QueryFilters, pagePar

return pagedQuery(
`
with sessions as (
select
session_id as id,
website_id as websiteId,
Expand All @@ -51,6 +52,8 @@ async function clickhouseQuery(websiteId: string, filters: QueryFilters, pagePar
${filterQuery}
group by session_id, website_id, hostname, browser, os, device, screen, language, country, subdivision1, city
order by lastAt desc
limit 1000)
select * from sessions
`,
params,
pageParams,
Expand Down

0 comments on commit 3805a0b

Please sign in to comment.