# It seems to be affecting our largest customers first

## Introduction

### Warm-up

1️⃣ **Have you ever had a production issue where a query suddenly became very slow?**  
What was the root cause, and how did you investigate it?

2️⃣ **What would you do if a critical dashboard endpoint started timing out during peak hours?**  
Describe the first three steps you would take to diagnose the problem.

3️⃣ **Have you ever dealt with rapid data growth in a database?**  
What strategies did you use (or would you use) to prevent performance degradation over time?

* * *

## Speaking

### Dialog

**Bill:** Hey, we’re `having an issue` in production. The `dashboard endpoint` is `timing out`. Users are reporting that it `either` takes forever to load or returns a 504 error.  
It seems to be affecting our largest customers first.

**Patrick:** Alright. Do you have the exact query that the endpoint is `running`? And what’s the current `average execution time` compared to normal?  
I’d also like to know if this is happening consistently or only `during peak hours.`

**Bill:** Yes, I `pulled it from` the logs. It used to run in about 200 milliseconds. Since this morning, it’s fluctuating between 8 and 12 seconds. The slow query log confirms the `spike`.

**Patrick:** That’s a `significant degradation`. Did anything change recently? Any schema modifications, deployments, or noticeable `data growth`? Performance issues usually correlate with some recent change.

**Bill:** We deployed a migration yesterday. We added a new column and updated some constraints. Also, the transactions table grew quite a bit this week due to a marketing campaign. We inserted a large `batch of records` over the weekend.

**Patrick:** That could definitely impact performance. Let me check the execution plan. Did you already run an EXPLAIN or EXPLAIN ANALYZE? The actual execution plan will tell us where the time is being spent.

**Bill:**  
I ran EXPLAIN, but I’m not sure how to interpret it. It showed high cost numbers and a lot of rows being processed.

**Patrick:** No problem. I’m looking at it now. I can see it’s performing a `full table scan` on the transactions table. That explains the increase in latency. It’s scanning millions of rows before applying the filter.

* * *

* * *

### Vocabulary

\[having an issue, `timing out,` dashboard endpoint, either, run a query, during peak hours, average execution time, data growth, pulled it from, spike, significant degradation, batch of records, full table scan \]

<table style="min-width: 100px;"><colgroup><col style="min-width: 25px;"><col style="min-width: 25px;"><col style="min-width: 25px;"><col style="min-width: 25px;"></colgroup><tbody><tr><th colspan="1" rowspan="1"><p>Expression</p></th><th colspan="1" rowspan="1"><p>Portuguese</p></th><th colspan="1" rowspan="1"><p>Explanation (English)</p></th><th colspan="1" rowspan="1"><p>Example Sentence</p></th></tr><tr><td colspan="1" rowspan="1"><p><strong>having an issue</strong></p></td><td colspan="1" rowspan="1"><p>estar enfrentando um problema</p></td><td colspan="1" rowspan="1"><p>Experiencing a problem or difficulty.</p></td><td colspan="1" rowspan="1"><p>We’re having an issue with the payment gateway in production.</p></td></tr><tr><td colspan="1" rowspan="1"><p><strong>timing out</strong></p></td><td colspan="1" rowspan="1"><p>exceder o tempo limite</p></td><td colspan="1" rowspan="1"><p>When a system stops waiting for a response because it took too long.</p></td><td colspan="1" rowspan="1"><p>The API request is timing out after 30 seconds.</p></td></tr><tr><td colspan="1" rowspan="1"><p><strong>run a query</strong></p></td><td colspan="1" rowspan="1"><p>executar uma consulta</p></td><td colspan="1" rowspan="1"><p>To execute a database command to retrieve or manipulate data.</p></td><td colspan="1" rowspan="1"><p>I ran a query to check how many users signed up today.</p></td></tr><tr><td colspan="1" rowspan="1"><p><strong>data growth</strong></p></td><td colspan="1" rowspan="1"><p>crescimento de dados</p></td><td colspan="1" rowspan="1"><p>The increase in the volume of stored data over time.</p></td><td colspan="1" rowspan="1"><p>Rapid data growth can impact database performance.</p></td></tr><tr><td colspan="1" rowspan="1"><p><strong>average execution time</strong></p></td><td colspan="1" rowspan="1"><p>tempo médio de execução</p></td><td colspan="1" rowspan="1"><p>The typical time it takes for a query or process to complete.</p></td><td colspan="1" rowspan="1"><p>The average execution time increased from 200ms to 10 seconds.</p></td></tr><tr><td colspan="1" rowspan="1"><p><strong>dashboard endpoint</strong></p></td><td colspan="1" rowspan="1"><p>endpoint do painel (dashboard)</p></td><td colspan="1" rowspan="1"><p>A backend route or API that provides data to a dashboard interface.</p></td><td colspan="1" rowspan="1"><p>The dashboard endpoint aggregates metrics from multiple services.</p></td></tr><tr><td colspan="1" rowspan="1"><p><strong>during peak hours</strong></p></td><td colspan="1" rowspan="1"><p>durante o horário de pico</p></td><td colspan="1" rowspan="1"><p>The busiest time period when system usage is highest.</p></td><td colspan="1" rowspan="1"><p>The system becomes slower during peak hours.</p></td></tr><tr><td colspan="1" rowspan="1"><p><strong>pulled it from</strong></p></td><td colspan="1" rowspan="1"><p>extrai / peguei de</p></td><td colspan="1" rowspan="1"><p>Retrieved information from a specific source.</p></td><td colspan="1" rowspan="1"><p>I pulled it from the application logs.</p></td></tr><tr><td colspan="1" rowspan="1"><p><strong>spike</strong></p></td><td colspan="1" rowspan="1"><p>pico / aumento repentino</p></td><td colspan="1" rowspan="1"><p>A sudden and sharp increase.</p></td><td colspan="1" rowspan="1"><p>We saw a spike in database load after the deployment.</p></td></tr><tr><td colspan="1" rowspan="1"><p><strong>batch of records</strong></p></td><td colspan="1" rowspan="1"><p>lote de registros</p></td><td colspan="1" rowspan="1"><p>A large group of records processed together.</p></td><td colspan="1" rowspan="1"><p>The job inserted a batch of records overnight.</p></td></tr><tr><td colspan="1" rowspan="1"><p><strong>significant degradation</strong></p></td><td colspan="1" rowspan="1"><p>degradação significativa</p></td><td colspan="1" rowspan="1"><p>A noticeable decline in performance or quality.</p></td><td colspan="1" rowspan="1"><p>There was a significant degradation in response time.</p></td></tr><tr><td colspan="1" rowspan="1"><p><strong>full table scan</strong></p></td><td colspan="1" rowspan="1"><p>varredura completa da tabela</p></td><td colspan="1" rowspan="1"><p>When the database reads every row in a table to find matching results.</p></td><td colspan="1" rowspan="1"><p>Without an index, the database performs a full table scan.---</p></td></tr></tbody></table>

* * *

* * *

## Exercises

### Reading Comprehension Questions

1.  What was the **original average execution time** of the query, and how much did it increase?
    
2.  Why did Patrick suspect that the issue might be related to a recent change?
    
3.  What caused the **full table scan**, and why is it problematic for large tables?
    
4.  How did **data growth** contribute to the performance issue?
    

* * *

### Fill-in-the-Blanks

Use the words below to complete the sentences:

**Word Bank:**  
(having an issue, timing out, run a query, data growth, average execution time, dashboard endpoint, during peak hours, pulled it from, spike, batch of records, significant degradation, full table scan)

* * *

1.  We are \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ with the reporting service in production.
    
2.  The API keeps \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ after 30 seconds.
    
3.  I decided to \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ to check the number of failed transactions.
    
4.  The system became unstable due to rapid \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ over the past month.
    
5.  The \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ increased from 200ms to 10 seconds.
    
6.  The \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ is responsible for loading the metrics page.
    
7.  The slowdown is worse \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ when more users are online.
    
8.  I \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ the execution plan from the database logs.
    
9.  We noticed a sudden \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ in CPU usage.
    
10.  The job inserted a large \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ over the weekend.
     
11.  There was a \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ in performance after the migration.
     
12.  Because there was no proper index, the database performed a \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_.
     

* * *

### Role-Play Activity

Use the words below to create one role-play (Conversation between two people).

**Word Bank:**  
(having an issue, timing out, run a query, data growth, average execution time, dashboard endpoint, during peak hours, pulled it from, spike, batch of records, significant degradation, full table scan)

* * *

## Done

* * *
