# Aggregate Operation Analysis

+ Create an index
+ Execution plan


![left](./student-guide/diagram/01-32-1.png)

```
ALTER TABLE t1 ADD INDEX idx_dt
```

------------------------------------------------------------

From the execution plan, because there is no index on the k field, it is impossible to use the index for filtering and count counting. The TableFullScan full table scan scans about 10 million records (based on statistical estimates), and after filtering by the Selection operator, there are about 1.2 million records (based on statistical estimates), executed The time is about 2.8 seconds, how can this be optimized? We see that the full table has about 10 million records, and the number of eligible records is about 1.2 million. We can add an index to the k field, scan the index for about 120w of eligible data, and execute indexed SQL:

```
alter table t1 add index idx_dt
```

Then look at the execution plan:

(omitted)
