repos / pico

pico services mono repo
git clone https://github.com/picosh/pico.git

commit
98e7f62
parent
c3c3ade
author
Eric Bower
date
2026-01-16 20:33:07 -0500 EST
refactor(analytics): add indexes to improve query performance
2 files changed,  +10, -1
M Makefile
+2, -1
 1@@ -144,10 +144,11 @@ migrate:
 2 	$(DOCKER_CMD) exec -i $(DB_CONTAINER) psql -U $(PGUSER) -d $(PGDATABASE) < ./sql/migrations/20250418_add_project_post_idx_analytics.sql
 3 	$(DOCKER_CMD) exec -i $(DB_CONTAINER) psql -U $(PGUSER) -d $(PGDATABASE) < ./sql/migrations/20251217_add_access_logs_table.sql
 4 	$(DOCKER_CMD) exec -i $(DB_CONTAINER) psql -U $(PGUSER) -d $(PGDATABASE) < ./sql/migrations/20251226_add_pipe_monitoring.sql
 5+	$(DOCKER_CMD) exec -i $(DB_CONTAINER) psql -U $(PGUSER) -d $(PGDATABASE) < ./sql/migrations/20260116_add_analytics_filter_indexes.sql
 6 .PHONY: migrate
 7 
 8 latest:
 9-	$(DOCKER_CMD) exec -i $(DB_CONTAINER) psql -U $(PGUSER) -d $(PGDATABASE) < ./sql/migrations/20251226_add_pipe_monitoring.sql
10+	$(DOCKER_CMD) exec -i $(DB_CONTAINER) psql -U $(PGUSER) -d $(PGDATABASE) < ./sql/migrations/20260116_add_analytics_filter_indexes.sql
11 .PHONY: latest
12 
13 psql:
A sql/migrations/20260116_add_analytics_filter_indexes.sql
+8, -0
1@@ -0,0 +1,8 @@
2+CREATE INDEX analytics_visits_user_created_idx 
3+  ON analytics_visits(user_id, created_at DESC);
4+
5+CREATE INDEX analytics_visits_user_host_created_status_idx 
6+  ON analytics_visits(user_id, host, created_at DESC, status);
7+
8+CREATE INDEX analytics_visits_user_path_created_status_idx 
9+  ON analytics_visits(user_id, path, created_at DESC, status);