-
-
Notifications
You must be signed in to change notification settings - Fork 730
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: add migration for traffic data collection #6171
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
` | ||
CREATE TABLE IF NOT EXISTS stat_traffic_usage( | ||
day DATE NOT NULL, | ||
traffic_group TEXT NOT NULL, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ended up naming this traffic_group as the group
name we initially came up with was a reserved keyword in Postgresql
CREATE TABLE IF NOT EXISTS stat_traffic_usage( | ||
day DATE NOT NULL, | ||
traffic_group TEXT NOT NULL, | ||
status_code_series INT NOT NULL, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
appended a _series to make it clear that it's 200/300 etc, not 200/201/202/304 etc
@gardleopard , @sjaanus do you think this would do for storing 400 days of data for visitation stats? |
I think creating subindexes on day, traffic_group and status_code_series could help. the PK index will be a thruple of (day, tg, scs), so if we want to do where status_code_series = 200 it will be a table scan. |
Thanks @chriswk - I've added the suggested indexes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
About the changes
Adds migration for creating table
stat_traffic_usage
.This table primary-keys on day, traffic_group, and status_code_series.
Traffic group is the grouping for API endpoints for which traffic is counted.
status_code_series is 200/202 etc = 200, 304 etc = 300