The company you work for has added many new web apps to its growing platform of marketing tools - mainly through acquisitions and mergers. Meanwhile, customer complaints about slow loading times have risen over the past few months. The CEO is unhappy and assigned a colleague with finding the cause. He wrote an app to collect detailed performance logs for the millions of requests each day and display them in a dashboard for each team to track down their issues.
Or you thought he was working on it. Nobody has seen him in weeks... Some say he finally got fed up with software development and moved to a cabin in the woods without internet. It's just rumors. But the project remains unfinished and it's now your responsibility. After digging into the codebase, you can import data for this morning.
But the dashboard performs poorly. It takes close to 30 seconds to analyze a few hours of data. Once you import weeks of performance profiles, it may not work at all. Ironically, an application meant to fix slow performance has slow performance itself...
After reviewing the code, you notice that all dashboard queries share a similar pattern. They filter rows for a specific team and time range and then aggregate the data by some metric (e.g. server, geolocation, browser) to provide insights into an apps performance.
SELECT
DATE_TRUNC('day', time) AS day,
DATE(time) AS day,
STRFTIME('%Y-%m-%d', time) AS day,
server_id,
url_path,
COUNT(*) AS requests,
AVG(duration_total) AS duration_avg,
MIN(duration_total) AS duration_min,
MAX(duration_total) AS duration_max
FROM requests
WHERE url_domain = 'example.com' AND service = 'shop' AND time BETWEEN '2026-05-01' AND '2026-05-31'
GROUP BY server_id, url_path, day You and your colleagues start reviewing the schema carefully. The performance improves after creating perfect indexes for the dashboard's queries. Each query now executes in about one second, which is an acceptable outcome - but not perfect.
However, the speedup disappeared after more data was imported for testing. What will the performance be like with more data? You write a script to import more data step-by-step and benchmark the dashboard's loading time.
The results speak for themselves: The dashboard will be painfully slow! But you're stuck as you've already tried everything you could think of - and your team is out of ideas too. Everything looks perfectly optimized but performance is still disappointing...
The last option is to ask an AI for help. They should be able to suggest some improvements as they've been trained on massive knowledge.
Looking back, the database choice for this project wasn't the best. But at least you don't have to struggle with query optimization anymore - it's clear that there's little room for improvement.
The AI's suggestion to use TimescaleDB only for the analytics tables is a great plan. You can improve the dashboard's queries without changing other parts of the app to use a different database.
Let's start with hypertables as we explore TimescaleDB.