# `VERSION::6.1.0` Online Scaling in `TiFlash` (On-premises)

+ Step 1: Adjust the replica number
  + Query whether any table has TiFlash replicas more than the number of TiFlash nodes after scale-in
  + For all tables with TiFlash replicas more than the number of TiFlash nodes after scale-in, adjust the TiFlash replica number
  + Repeat previous steps, until there is no table with TiFlash replicas more than the number of TiFlash nodes after scale-in 

```
/* Query whether any table has TiFlash replicas more than the number of TiFlash nodes after scale-in */
SELECT * FROM information_schema.tiflash_replica WHERE REPLICA_COUNT  >  'tobe_left_nodes';

/* For all tables with TiFlash replicas more than the number of TiFlash nodes after scale-in, adjust the TiFlash replica number */
ALTER TABLE <db-name>.<table-name> SET tiflash replica 'new_replica_num';
```

![`smart`](./student-guide/diagram/OnlineScalingInTiFlashNodes_aa_001_20220923.png)
-------------------------------------------------------------
Recall that in TiDB, data are split into regions. Regions are replicated to form Raft Group. The data in TiFlash is also organised in Regions.

There is no logical relationship between the number of TiFlash node and the number of TiFlash replicas. However, TiDB enforces that the number of TiFlash nodes must larger than or equal to the number of replicas.

Please refer to the documentation: https://docs.pingcap.com/tidb/v6.1/scale-tidb-using-tiup  for detail.








