You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by zy...@apache.org on 2022/11/21 00:32:58 UTC

[iotdb] branch master updated: Remove useless code of schema template for old standalone (#8058)

This is an automated email from the ASF dual-hosted git repository.

zyk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 8755c3fbea Remove useless code of schema template for old standalone (#8058)
8755c3fbea is described below

commit 8755c3fbeabe078ea7a4b1bb6e013db905d6e6a6
Author: Marcos_Zyk <38...@users.noreply.github.com>
AuthorDate: Mon Nov 21 08:32:51 2022 +0800

    Remove useless code of schema template for old standalone (#8058)
    
    Remove useless code of schema template for old standalone (#8058)
---
 .../schemaregion/rocksdb/RSchemaRegion.java        |   56 -
 .../schemaregion/rocksdb/mnode/RInternalMNode.java |   24 -
 .../rocksdb/mnode/RMeasurementMNode.java           |   15 -
 .../metadata/tagSchemaRegion/TagSchemaRegion.java  |   40 -
 .../org/apache/iotdb/db/conf/IoTDBStartCheck.java  |    2 -
 .../iotdb/db/localconfignode/LocalConfigNode.java  |  205 +---
 .../iotdb/db/metadata/LocalSchemaProcessor.java    |  196 +---
 .../idtable/entry/InsertMeasurementMNode.java      |   16 -
 .../iotdb/db/metadata/logfile/MLogWriter.java      |   41 -
 .../org/apache/iotdb/db/metadata/mnode/IMNode.java |    7 -
 .../iotdb/db/metadata/mnode/InternalMNode.java     |   32 -
 .../iotdb/db/metadata/mnode/MeasurementMNode.java  |   17 -
 .../iotdb/db/metadata/mtree/IMTreeBelowSG.java     |   66 --
 .../db/metadata/mtree/MTreeBelowSGCachedImpl.java  |  625 +---------
 .../db/metadata/mtree/MTreeBelowSGMemoryImpl.java  |  566 +--------
 .../store/disk/schemafile/MockSchemaFile.java      |    1 -
 .../mtree/store/disk/schemafile/RecordUtils.java   |   14 +-
 .../mtree/store/disk/schemafile/SchemaFile.java    |   10 +-
 .../db/metadata/mtree/traverser/Traverser.java     |   51 +-
 .../plan/schemaregion/SchemaRegionPlanType.java    |    6 +-
 .../plan/schemaregion/SchemaRegionPlanVisitor.java |   15 -
 .../impl/ActivateTemplatePlanImpl.java             |   44 -
 .../impl/SchemaRegionPlanDeserializer.java         |   40 -
 .../schemaregion/impl/SchemaRegionPlanFactory.java |   11 -
 .../impl/SchemaRegionPlanSerializer.java           |   49 -
 .../impl/SchemaRegionPlanTxtSerializer.java        |   29 -
 .../schemaregion/impl/SetTemplatePlanImpl.java     |   69 --
 .../schemaregion/impl/UnsetTemplatePlanImpl.java   |   69 --
 .../schemaregion/write/IActivateTemplatePlan.java  |   42 -
 .../plan/schemaregion/write/ISetTemplatePlan.java  |   45 -
 .../schemaregion/write/IUnsetTemplatePlan.java     |   45 -
 .../db/metadata/schemaregion/ISchemaRegion.java    |   28 -
 .../schemaregion/SchemaRegionMemoryImpl.java       |  217 ----
 .../schemaregion/SchemaRegionSchemaFileImpl.java   |  227 ----
 .../db/metadata/template/TemplateLogReader.java    |   46 -
 .../db/metadata/template/TemplateLogWriter.java    |   64 -
 .../db/metadata/template/TemplateManager.java      |  384 ------
 .../db/metadata/upgrade/MetadataUpgrader.java      |  437 -------
 .../apache/iotdb/db/qp/executor/PlanExecutor.java  |   86 +-
 .../db/qp/physical/sys/ActivateTemplatePlan.java   |    4 +-
 .../iotdb/db/qp/physical/sys/SetTemplatePlan.java  |    3 +-
 .../db/qp/physical/sys/UnsetTemplatePlan.java      |    3 +-
 .../db/service/thrift/impl/TSServiceImpl.java      |  103 --
 .../apache/iotdb/db/metadata/SchemaBasicTest.java  | 1241 ++------------------
 .../org/apache/iotdb/db/metadata/TemplateTest.java |  307 +----
 .../plan/SchemaRegionPlanCompatibilityTest.java    |   55 -
 .../schemaRegion/SchemaRegionBasicTest.java        |   10 +-
 .../db/metadata/upgrade/MetadataUpgradeTest.java   |  318 -----
 .../org/apache/iotdb/db/tools/MLogParserTest.java  |   41 +-
 49 files changed, 220 insertions(+), 5802 deletions(-)

diff --git a/schema-engine-rocksdb/src/main/java/org/apache/iotdb/db/metadata/schemaregion/rocksdb/RSchemaRegion.java b/schema-engine-rocksdb/src/main/java/org/apache/iotdb/db/metadata/schemaregion/rocksdb/RSchemaRegion.java
index 846a13bf8d..fe67e2898c 100644
--- a/schema-engine-rocksdb/src/main/java/org/apache/iotdb/db/metadata/schemaregion/rocksdb/RSchemaRegion.java
+++ b/schema-engine-rocksdb/src/main/java/org/apache/iotdb/db/metadata/schemaregion/rocksdb/RSchemaRegion.java
@@ -48,15 +48,12 @@ import org.apache.iotdb.db.metadata.mnode.IMeasurementMNode;
 import org.apache.iotdb.db.metadata.mnode.IStorageGroupMNode;
 import org.apache.iotdb.db.metadata.mnode.MNodeType;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IActivateTemplateInClusterPlan;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.IActivateTemplatePlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IAutoCreateDeviceMNodePlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.ICreateAlignedTimeSeriesPlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.ICreateTimeSeriesPlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IDeactivateTemplatePlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IPreDeactivateTemplatePlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IRollbackPreDeactivateTemplatePlan;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.ISetTemplatePlan;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.IUnsetTemplatePlan;
 import org.apache.iotdb.db.metadata.schemaregion.ISchemaRegion;
 import org.apache.iotdb.db.metadata.schemaregion.SchemaRegionUtils;
 import org.apache.iotdb.db.metadata.schemaregion.rocksdb.mnode.REntityMNode;
@@ -1315,29 +1312,6 @@ public class RSchemaRegion implements ISchemaRegion {
     return allResult;
   }
 
-  @Override
-  public List<MeasurementPath> getAllMeasurementByDevicePath(PartialPath devicePath)
-      throws PathNotExistException {
-    List<MeasurementPath> result = new ArrayList<>();
-    String nextLevelPathName =
-        RSchemaUtils.convertPartialPathToInner(
-            devicePath.getFullPath(), devicePath.getNodeLength() + 1, NODE_TYPE_MEASUREMENT);
-    Map<byte[], byte[]> allMeasurementPath =
-        readWriteHandler.getKeyValueByPrefix(nextLevelPathName);
-    for (Map.Entry<byte[], byte[]> entry : allMeasurementPath.entrySet()) {
-      PartialPath pathName;
-      try {
-        pathName = new PartialPath(new String(entry.getKey()));
-      } catch (IllegalPathException e) {
-        throw new PathNotExistException(e.getMessage());
-      }
-      MeasurementSchema measurementSchema =
-          (MeasurementSchema) RSchemaUtils.parseNodeValue(entry.getValue(), RMNodeValueType.SCHEMA);
-      result.add(new MeasurementPath(pathName, measurementSchema));
-    }
-    return result;
-  }
-
   @Override
   public IMNode getDeviceNode(PartialPath path) throws MetadataException {
     String[] nodes = path.getNodes();
@@ -1866,36 +1840,6 @@ public class RSchemaRegion implements ISchemaRegion {
     }
   }
 
-  @Override
-  public Set<String> getPathsSetTemplate(String templateName) throws MetadataException {
-    throw new UnsupportedOperationException();
-  }
-
-  @Override
-  public Set<String> getPathsUsingTemplate(String templateName) throws MetadataException {
-    throw new UnsupportedOperationException();
-  }
-
-  @Override
-  public boolean isTemplateAppendable(Template template, List<String> measurements) {
-    throw new UnsupportedOperationException();
-  }
-
-  @Override
-  public void setSchemaTemplate(ISetTemplatePlan plan) throws MetadataException {
-    throw new UnsupportedOperationException();
-  }
-
-  @Override
-  public void unsetSchemaTemplate(IUnsetTemplatePlan plan) throws MetadataException {
-    throw new UnsupportedOperationException();
-  }
-
-  @Override
-  public void setUsingSchemaTemplate(IActivateTemplatePlan plan) throws MetadataException {
-    throw new UnsupportedOperationException();
-  }
-
   @Override
   public void activateSchemaTemplate(IActivateTemplateInClusterPlan plan, Template template)
       throws MetadataException {
diff --git a/schema-engine-rocksdb/src/main/java/org/apache/iotdb/db/metadata/schemaregion/rocksdb/mnode/RInternalMNode.java b/schema-engine-rocksdb/src/main/java/org/apache/iotdb/db/metadata/schemaregion/rocksdb/mnode/RInternalMNode.java
index 2ee98b909d..4b9680472f 100644
--- a/schema-engine-rocksdb/src/main/java/org/apache/iotdb/db/metadata/schemaregion/rocksdb/mnode/RInternalMNode.java
+++ b/schema-engine-rocksdb/src/main/java/org/apache/iotdb/db/metadata/schemaregion/rocksdb/mnode/RInternalMNode.java
@@ -27,7 +27,6 @@ import org.apache.iotdb.db.metadata.mnode.container.IMNodeContainer;
 import org.apache.iotdb.db.metadata.schemaregion.rocksdb.RSchemaConstants;
 import org.apache.iotdb.db.metadata.schemaregion.rocksdb.RSchemaReadWriteHandler;
 import org.apache.iotdb.db.metadata.schemaregion.rocksdb.RSchemaUtils;
-import org.apache.iotdb.db.metadata.template.Template;
 
 import org.rocksdb.RocksDBException;
 
@@ -35,9 +34,6 @@ import java.io.IOException;
 
 public class RInternalMNode extends RMNode {
 
-  // schema template
-  protected Template schemaTemplate = null;
-
   private volatile boolean useTemplate = false;
 
   /**
@@ -161,26 +157,6 @@ public class RInternalMNode extends RMNode {
     throw new UnsupportedOperationException();
   }
 
-  /**
-   * get upper template of this node, remember we get nearest template alone this node to root
-   *
-   * @return upper template
-   */
-  @Override
-  public Template getUpperTemplate() {
-    throw new UnsupportedOperationException();
-  }
-
-  @Override
-  public Template getSchemaTemplate() {
-    return schemaTemplate;
-  }
-
-  @Override
-  public void setSchemaTemplate(Template schemaTemplate) {
-    this.schemaTemplate = schemaTemplate;
-  }
-
   @Override
   public MNodeType getMNodeType(Boolean isConfig) {
     return isConfig ? MNodeType.SG_INTERNAL : MNodeType.INTERNAL;
diff --git a/schema-engine-rocksdb/src/main/java/org/apache/iotdb/db/metadata/schemaregion/rocksdb/mnode/RMeasurementMNode.java b/schema-engine-rocksdb/src/main/java/org/apache/iotdb/db/metadata/schemaregion/rocksdb/mnode/RMeasurementMNode.java
index b6380cdbaa..d5bdbd8a6f 100644
--- a/schema-engine-rocksdb/src/main/java/org/apache/iotdb/db/metadata/schemaregion/rocksdb/mnode/RMeasurementMNode.java
+++ b/schema-engine-rocksdb/src/main/java/org/apache/iotdb/db/metadata/schemaregion/rocksdb/mnode/RMeasurementMNode.java
@@ -31,7 +31,6 @@ import org.apache.iotdb.db.metadata.mnode.container.IMNodeContainer;
 import org.apache.iotdb.db.metadata.schemaregion.rocksdb.RSchemaConstants;
 import org.apache.iotdb.db.metadata.schemaregion.rocksdb.RSchemaReadWriteHandler;
 import org.apache.iotdb.db.metadata.schemaregion.rocksdb.RSchemaUtils;
-import org.apache.iotdb.db.metadata.template.Template;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
 import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
 import org.apache.iotdb.tsfile.write.schema.IMeasurementSchema;
@@ -216,20 +215,6 @@ public class RMeasurementMNode extends RMNode implements IMeasurementMNode {
     throw new UnsupportedOperationException();
   }
 
-  @Override
-  public Template getUpperTemplate() {
-    throw new UnsupportedOperationException();
-  }
-
-  @Override
-  public void setSchemaTemplate(Template schemaTemplate) {}
-
-  @Override
-  public Template getSchemaTemplate() {
-    throw new RuntimeException(
-        String.format("current node %s is a MeasurementMNode, can not get Device Template", name));
-  }
-
   @Override
   public void setUseTemplate(boolean useTemplate) {}
 
diff --git a/schema-engine-tag/src/main/java/org/apache/iotdb/db/metadata/tagSchemaRegion/TagSchemaRegion.java b/schema-engine-tag/src/main/java/org/apache/iotdb/db/metadata/tagSchemaRegion/TagSchemaRegion.java
index df3d187d10..442e541781 100644
--- a/schema-engine-tag/src/main/java/org/apache/iotdb/db/metadata/tagSchemaRegion/TagSchemaRegion.java
+++ b/schema-engine-tag/src/main/java/org/apache/iotdb/db/metadata/tagSchemaRegion/TagSchemaRegion.java
@@ -44,15 +44,12 @@ import org.apache.iotdb.db.metadata.mnode.IMNode;
 import org.apache.iotdb.db.metadata.mnode.IMeasurementMNode;
 import org.apache.iotdb.db.metadata.mnode.IStorageGroupMNode;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IActivateTemplateInClusterPlan;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.IActivateTemplatePlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IAutoCreateDeviceMNodePlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.ICreateAlignedTimeSeriesPlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.ICreateTimeSeriesPlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IDeactivateTemplatePlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IPreDeactivateTemplatePlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IRollbackPreDeactivateTemplatePlan;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.ISetTemplatePlan;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.IUnsetTemplatePlan;
 import org.apache.iotdb.db.metadata.schemaregion.ISchemaRegion;
 import org.apache.iotdb.db.metadata.schemaregion.SchemaRegionUtils;
 import org.apache.iotdb.db.metadata.tagSchemaRegion.idtable.IDTableWithDeviceIDListImpl;
@@ -672,12 +669,6 @@ public class TagSchemaRegion implements ISchemaRegion {
     }
   }
 
-  @Override
-  public List<MeasurementPath> getAllMeasurementByDevicePath(PartialPath devicePath)
-      throws PathNotExistException {
-    throw new UnsupportedOperationException("getAllMeasurementByDevicePath");
-  }
-
   @Override
   public IMNode getDeviceNode(PartialPath path) throws MetadataException {
     DeviceEntry deviceEntry = idTableWithDeviceIDList.getDeviceEntry(path.getFullPath());
@@ -815,37 +806,6 @@ public class TagSchemaRegion implements ISchemaRegion {
     createAlignedTimeSeries(prefixPath, measurements, dataTypes, encodings, compressors);
   }
 
-  @Override
-  public Set<String> getPathsSetTemplate(String templateName) throws MetadataException {
-    throw new UnsupportedOperationException("getPathsSetTemplate");
-  }
-
-  @Override
-  public Set<String> getPathsUsingTemplate(String templateName) throws MetadataException {
-    throw new UnsupportedOperationException("getPathsUsingTemplate");
-  }
-
-  @Override
-  public boolean isTemplateAppendable(Template template, List<String> measurements)
-      throws MetadataException {
-    throw new UnsupportedOperationException("isTemplateAppendable");
-  }
-
-  @Override
-  public void setSchemaTemplate(ISetTemplatePlan plan) throws MetadataException {
-    throw new UnsupportedOperationException("setSchemaTemplate");
-  }
-
-  @Override
-  public void unsetSchemaTemplate(IUnsetTemplatePlan plan) throws MetadataException {
-    throw new UnsupportedOperationException("unsetSchemaTemplate");
-  }
-
-  @Override
-  public void setUsingSchemaTemplate(IActivateTemplatePlan plan) throws MetadataException {
-    throw new UnsupportedOperationException("setUsingSchemaTemplate");
-  }
-
   @Override
   public void activateSchemaTemplate(IActivateTemplateInClusterPlan plan, Template template)
       throws MetadataException {
diff --git a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBStartCheck.java b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBStartCheck.java
index 7b6d031a23..5cda30853c 100644
--- a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBStartCheck.java
+++ b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBStartCheck.java
@@ -28,7 +28,6 @@ import org.apache.iotdb.commons.file.SystemFileFactory;
 import org.apache.iotdb.confignode.rpc.thrift.TGlobalConfig;
 import org.apache.iotdb.consensus.ConsensusFactory;
 import org.apache.iotdb.db.conf.directories.DirectoryChecker;
-import org.apache.iotdb.db.metadata.upgrade.MetadataUpgrader;
 import org.apache.iotdb.db.wal.utils.WALMode;
 import org.apache.iotdb.tsfile.common.conf.TSFileConfig;
 import org.apache.iotdb.tsfile.common.conf.TSFileDescriptor;
@@ -294,7 +293,6 @@ public class IoTDBStartCheck {
     } else if (versionString.startsWith("0.12") || versionString.startsWith("0.13")) {
       checkWALNotExists();
       upgradePropertiesFile();
-      MetadataUpgrader.upgrade();
     }
     checkProperties();
   }
diff --git a/server/src/main/java/org/apache/iotdb/db/localconfignode/LocalConfigNode.java b/server/src/main/java/org/apache/iotdb/db/localconfignode/LocalConfigNode.java
index 99eb51cb96..8198b77005 100644
--- a/server/src/main/java/org/apache/iotdb/db/localconfignode/LocalConfigNode.java
+++ b/server/src/main/java/org/apache/iotdb/db/localconfignode/LocalConfigNode.java
@@ -66,10 +66,8 @@ import org.apache.iotdb.db.engine.cache.TimeSeriesMetadataCache;
 import org.apache.iotdb.db.engine.storagegroup.DataRegion;
 import org.apache.iotdb.db.exception.DataRegionException;
 import org.apache.iotdb.db.exception.StorageEngineException;
-import org.apache.iotdb.db.exception.metadata.PathNotExistException;
 import org.apache.iotdb.db.exception.metadata.StorageGroupAlreadySetException;
 import org.apache.iotdb.db.exception.metadata.StorageGroupNotSetException;
-import org.apache.iotdb.db.exception.metadata.template.UndefinedTemplateException;
 import org.apache.iotdb.db.exception.query.QueryProcessException;
 import org.apache.iotdb.db.exception.sql.StatementAnalyzeException;
 import org.apache.iotdb.db.metadata.LocalSchemaProcessor;
@@ -78,28 +76,18 @@ import org.apache.iotdb.db.metadata.schemaregion.ISchemaRegion;
 import org.apache.iotdb.db.metadata.schemaregion.SchemaEngine;
 import org.apache.iotdb.db.metadata.storagegroup.IStorageGroupSchemaManager;
 import org.apache.iotdb.db.metadata.storagegroup.StorageGroupSchemaManager;
-import org.apache.iotdb.db.metadata.template.Template;
-import org.apache.iotdb.db.metadata.template.TemplateManager;
 import org.apache.iotdb.db.metadata.utils.MetaUtils;
 import org.apache.iotdb.db.mpp.plan.constant.DataNodeEndPoints;
 import org.apache.iotdb.db.mpp.plan.statement.sys.AuthorStatement;
 import org.apache.iotdb.db.mpp.plan.statement.sys.sync.CreatePipeSinkStatement;
 import org.apache.iotdb.db.mpp.plan.statement.sys.sync.CreatePipeStatement;
 import org.apache.iotdb.db.qp.logical.sys.AuthorOperator;
-import org.apache.iotdb.db.qp.physical.sys.ActivateTemplatePlan;
-import org.apache.iotdb.db.qp.physical.sys.AppendTemplatePlan;
-import org.apache.iotdb.db.qp.physical.sys.CreateTemplatePlan;
-import org.apache.iotdb.db.qp.physical.sys.DropTemplatePlan;
-import org.apache.iotdb.db.qp.physical.sys.PruneTemplatePlan;
-import org.apache.iotdb.db.qp.physical.sys.SetTemplatePlan;
-import org.apache.iotdb.db.qp.physical.sys.UnsetTemplatePlan;
 import org.apache.iotdb.db.rescon.MemTableManager;
 import org.apache.iotdb.db.sync.SyncService;
 import org.apache.iotdb.db.utils.sync.SyncPipeUtil;
 import org.apache.iotdb.rpc.RpcUtils;
 import org.apache.iotdb.rpc.TSStatusCode;
 import org.apache.iotdb.tsfile.utils.Pair;
-import org.apache.iotdb.tsfile.write.schema.IMeasurementSchema;
 
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
@@ -121,7 +109,7 @@ import java.util.stream.Collectors;
 
 /**
  * This class simulates the behaviour of configNode to manage the configs locally. The schema
- * configs include database, schema region and template. The data config is dataRegion.
+ * configs include database and schema region. The data config is dataRegion.
  */
 public class LocalConfigNode {
 
@@ -135,7 +123,6 @@ public class LocalConfigNode {
 
   private final IStorageGroupSchemaManager storageGroupSchemaManager =
       StorageGroupSchemaManager.getInstance();
-  private final TemplateManager templateManager = TemplateManager.getInstance();
   private final SchemaEngine schemaEngine = SchemaEngine.getInstance();
   private final LocalSchemaPartitionTable schemaPartitionTable =
       LocalSchemaPartitionTable.getInstance();
@@ -189,8 +176,6 @@ public class LocalConfigNode {
     }
 
     try {
-
-      templateManager.init();
       storageGroupSchemaManager.init();
 
       Map<PartialPath, List<SchemaRegionId>> recoveredLocalSchemaRegionInfo =
@@ -238,7 +223,6 @@ public class LocalConfigNode {
       schemaPartitionTable.clear();
       schemaEngine.clear();
       storageGroupSchemaManager.clear();
-      templateManager.clear();
 
       dataPartitionInfo.clear();
 
@@ -255,7 +239,6 @@ public class LocalConfigNode {
     }
 
     storageGroupSchemaManager.forceLog();
-    templateManager.forceLog();
   }
 
   // endregion
@@ -291,10 +274,6 @@ public class LocalConfigNode {
     deleteSchemaRegionsInStorageGroup(
         storageGroup, schemaPartitionTable.getSchemaRegionIdsByStorageGroup(storageGroup));
 
-    for (Template template : templateManager.getTemplateMap().values()) {
-      templateManager.unmarkStorageGroup(template, storageGroup.getFullPath());
-    }
-
     if (!config.isEnableMemControl()) {
       MemTableManager.getInstance().addOrDeleteStorageGroup(-1);
     }
@@ -660,188 +639,6 @@ public class LocalConfigNode {
 
   // endregion
 
-  // region Interfaces and Implementation for Template operations
-  public void createSchemaTemplate(CreateTemplatePlan plan) throws MetadataException {
-    templateManager.createSchemaTemplate(plan);
-  }
-
-  public void appendSchemaTemplate(AppendTemplatePlan plan) throws MetadataException {
-    if (templateManager.getTemplate(plan.getName()) == null) {
-      throw new MetadataException(String.format("Template [%s] does not exist.", plan.getName()));
-    }
-
-    boolean isTemplateAppendable = true;
-
-    Template template = templateManager.getTemplate(plan.getName());
-
-    for (SchemaRegionId schemaRegionId : template.getRelatedSchemaRegion()) {
-      if (!schemaEngine
-          .getSchemaRegion(schemaRegionId)
-          .isTemplateAppendable(template, plan.getMeasurements())) {
-        isTemplateAppendable = false;
-        break;
-      }
-    }
-
-    if (!isTemplateAppendable) {
-      throw new MetadataException(
-          String.format(
-              "Template [%s] cannot be appended for overlapping of new measurement and MTree",
-              plan.getName()));
-    }
-
-    templateManager.appendSchemaTemplate(plan);
-  }
-
-  public void pruneSchemaTemplate(PruneTemplatePlan plan) throws MetadataException {
-    if (templateManager.getTemplate(plan.getName()) == null) {
-      throw new MetadataException(String.format("Template [%s] does not exist.", plan.getName()));
-    }
-
-    if (templateManager.getTemplate(plan.getName()).getRelatedSchemaRegion().size() > 0) {
-      throw new MetadataException(
-          String.format(
-              "Template [%s] cannot be pruned since had been set before.", plan.getName()));
-    }
-
-    templateManager.pruneSchemaTemplate(plan);
-  }
-
-  public int countMeasurementsInTemplate(String templateName) throws MetadataException {
-    try {
-      return templateManager.getTemplate(templateName).getMeasurementsCount();
-    } catch (UndefinedTemplateException e) {
-      throw new MetadataException(e);
-    }
-  }
-
-  /**
-   * @param templateName name of template to check
-   * @param path full path to check
-   * @return if path correspond to a measurement in template
-   * @throws MetadataException
-   */
-  public boolean isMeasurementInTemplate(String templateName, String path)
-      throws MetadataException {
-    return templateManager.getTemplate(templateName).isPathMeasurement(path);
-  }
-
-  public boolean isPathExistsInTemplate(String templateName, String path) throws MetadataException {
-    return templateManager.getTemplate(templateName).isPathExistInTemplate(path);
-  }
-
-  public List<String> getMeasurementsInTemplate(String templateName, String path)
-      throws MetadataException {
-    return templateManager.getTemplate(templateName).getMeasurementsUnderPath(path);
-  }
-
-  public List<Pair<String, IMeasurementSchema>> getSchemasInTemplate(
-      String templateName, String path) throws MetadataException {
-    Set<Map.Entry<String, IMeasurementSchema>> rawSchemas =
-        templateManager.getTemplate(templateName).getSchemaMap().entrySet();
-    return rawSchemas.stream()
-        .filter(e -> e.getKey().startsWith(path))
-        .collect(
-            ArrayList::new,
-            (res, elem) -> res.add(new Pair<>(elem.getKey(), elem.getValue())),
-            ArrayList::addAll);
-  }
-
-  public Set<String> getAllTemplates() {
-    return templateManager.getAllTemplateName();
-  }
-
-  /**
-   * Get all paths set designated template
-   *
-   * @param templateName designated template name, blank string for any template exists
-   * @return paths set
-   */
-  public Set<String> getPathsSetTemplate(String templateName) throws MetadataException {
-    Set<String> result = new HashSet<>();
-    if (templateName.equals(IoTDBConstant.ONE_LEVEL_PATH_WILDCARD)) {
-      for (ISchemaRegion schemaRegion : schemaEngine.getAllSchemaRegions()) {
-        result.addAll(schemaRegion.getPathsSetTemplate(IoTDBConstant.ONE_LEVEL_PATH_WILDCARD));
-      }
-    } else {
-      for (SchemaRegionId schemaRegionId :
-          templateManager.getTemplate(templateName).getRelatedSchemaRegion()) {
-        result.addAll(
-            schemaEngine.getSchemaRegion(schemaRegionId).getPathsSetTemplate(templateName));
-      }
-    }
-
-    return result;
-  }
-
-  public Set<String> getPathsUsingTemplate(String templateName) throws MetadataException {
-    Set<String> result = new HashSet<>();
-    if (templateName.equals(IoTDBConstant.ONE_LEVEL_PATH_WILDCARD)) {
-      for (ISchemaRegion schemaRegion : schemaEngine.getAllSchemaRegions()) {
-        result.addAll(schemaRegion.getPathsUsingTemplate(IoTDBConstant.ONE_LEVEL_PATH_WILDCARD));
-      }
-    } else {
-      for (SchemaRegionId schemaRegionId :
-          templateManager.getTemplate(templateName).getRelatedSchemaRegion()) {
-        result.addAll(
-            schemaEngine.getSchemaRegion(schemaRegionId).getPathsUsingTemplate(templateName));
-      }
-    }
-
-    return result;
-  }
-
-  public void dropSchemaTemplate(DropTemplatePlan plan) throws MetadataException {
-    String templateName = plan.getName();
-    // check whether template exists
-    if (!templateManager.getAllTemplateName().contains(templateName)) {
-      throw new UndefinedTemplateException(templateName);
-    }
-
-    if (templateManager.getTemplate(plan.getName()).getRelatedSchemaRegion().size() > 0) {
-      throw new MetadataException(
-          String.format(
-              "Template [%s] has been set on MTree, cannot be dropped now.", templateName));
-    }
-
-    templateManager.dropSchemaTemplate(plan);
-  }
-
-  public synchronized void setSchemaTemplate(SetTemplatePlan plan) throws MetadataException {
-    PartialPath path = new PartialPath(plan.getPrefixPath());
-    try {
-      schemaEngine
-          .getSchemaRegion(getBelongedSchemaRegionIdWithAutoCreate(path))
-          .setSchemaTemplate(plan);
-    } catch (StorageGroupAlreadySetException e) {
-      throw new MetadataException("Template should not be set above storageGroup");
-    }
-  }
-
-  public synchronized void unsetSchemaTemplate(UnsetTemplatePlan plan) throws MetadataException {
-    PartialPath path = new PartialPath(plan.getPrefixPath());
-    try {
-      schemaEngine.getSchemaRegion(getBelongedSchemaRegionId(path)).unsetSchemaTemplate(plan);
-    } catch (StorageGroupNotSetException e) {
-      throw new PathNotExistException(plan.getPrefixPath());
-    }
-  }
-
-  public void setUsingSchemaTemplate(ActivateTemplatePlan plan) throws MetadataException {
-    PartialPath path = plan.getPrefixPath();
-    try {
-      schemaEngine
-          .getSchemaRegion(getBelongedSchemaRegionIdWithAutoCreate(path))
-          .setUsingSchemaTemplate(plan);
-    } catch (StorageGroupNotSetException e) {
-      throw new MetadataException(
-          String.format(
-              "Path [%s] has not been set any template.", plan.getPrefixPath().toString()));
-    }
-  }
-
-  // endregion
-
   // region Interfaces for DataRegionId Management
 
   /**
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/LocalSchemaProcessor.java b/server/src/main/java/org/apache/iotdb/db/metadata/LocalSchemaProcessor.java
index db77aec828..2685cab423 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/LocalSchemaProcessor.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/LocalSchemaProcessor.java
@@ -31,7 +31,6 @@ import org.apache.iotdb.db.exception.metadata.MeasurementAlreadyExistException;
 import org.apache.iotdb.db.exception.metadata.PathAlreadyExistException;
 import org.apache.iotdb.db.exception.metadata.PathNotExistException;
 import org.apache.iotdb.db.exception.metadata.StorageGroupNotSetException;
-import org.apache.iotdb.db.exception.metadata.template.UndefinedTemplateException;
 import org.apache.iotdb.db.localconfignode.LocalConfigNode;
 import org.apache.iotdb.db.metadata.lastCache.LastCacheManager;
 import org.apache.iotdb.db.metadata.mnode.IMNode;
@@ -40,27 +39,11 @@ import org.apache.iotdb.db.metadata.mnode.IStorageGroupMNode;
 import org.apache.iotdb.db.metadata.rescon.SchemaStatisticsManager;
 import org.apache.iotdb.db.metadata.schemaregion.ISchemaRegion;
 import org.apache.iotdb.db.metadata.schemaregion.SchemaEngine;
-import org.apache.iotdb.db.metadata.template.Template;
-import org.apache.iotdb.db.metadata.template.TemplateManager;
 import org.apache.iotdb.db.qp.constant.SQLConstant;
-import org.apache.iotdb.db.qp.physical.PhysicalPlan;
-import org.apache.iotdb.db.qp.physical.sys.ActivateTemplatePlan;
-import org.apache.iotdb.db.qp.physical.sys.AppendTemplatePlan;
-import org.apache.iotdb.db.qp.physical.sys.AutoCreateDeviceMNodePlan;
-import org.apache.iotdb.db.qp.physical.sys.ChangeAliasPlan;
 import org.apache.iotdb.db.qp.physical.sys.CreateAlignedTimeSeriesPlan;
-import org.apache.iotdb.db.qp.physical.sys.CreateTemplatePlan;
 import org.apache.iotdb.db.qp.physical.sys.CreateTimeSeriesPlan;
-import org.apache.iotdb.db.qp.physical.sys.DeleteStorageGroupPlan;
-import org.apache.iotdb.db.qp.physical.sys.DeleteTimeSeriesPlan;
-import org.apache.iotdb.db.qp.physical.sys.DropTemplatePlan;
-import org.apache.iotdb.db.qp.physical.sys.PruneTemplatePlan;
-import org.apache.iotdb.db.qp.physical.sys.SetStorageGroupPlan;
-import org.apache.iotdb.db.qp.physical.sys.SetTTLPlan;
-import org.apache.iotdb.db.qp.physical.sys.SetTemplatePlan;
 import org.apache.iotdb.db.qp.physical.sys.ShowDevicesPlan;
 import org.apache.iotdb.db.qp.physical.sys.ShowTimeSeriesPlan;
-import org.apache.iotdb.db.qp.physical.sys.UnsetTemplatePlan;
 import org.apache.iotdb.db.query.context.QueryContext;
 import org.apache.iotdb.db.query.dataset.ShowDevicesResult;
 import org.apache.iotdb.db.query.dataset.ShowResult;
@@ -103,7 +86,6 @@ import static org.apache.iotdb.tsfile.common.constant.TsFileConstant.PATH_SEPARA
  *
  * <ol>
  *   <li>SchemaProcessor Singleton
- *   <li>Interfaces and Implementation of Operating PhysicalPlans of Metadata
  *   <li>Interfaces and Implementation for Timeseries operation
  *   <li>Interfaces and Implementation for StorageGroup and TTL operation
  *   <li>Interfaces for metadata info Query
@@ -118,7 +100,6 @@ import static org.apache.iotdb.tsfile.common.constant.TsFileConstant.PATH_SEPARA
  *   <li>Interfaces for alias and tag/attribute operations
  *   <li>Interfaces only for Cluster module usage
  *   <li>Interfaces for lastCache operations
- *   <li>Interfaces and Implementation for Template operations
  *   <li>Interfaces for Trigger
  *   <li>TestOnly Interfaces
  * </ol>
@@ -200,83 +181,6 @@ public class LocalSchemaProcessor {
 
   // endregion
 
-  // region Interfaces and Implementation of operating PhysicalPlans of Metadata
-  // This method is mainly used for Metadata Sync and  upgrade
-  public void operation(PhysicalPlan plan) throws IOException, MetadataException {
-    switch (plan.getOperatorType()) {
-      case CREATE_TIMESERIES:
-        CreateTimeSeriesPlan createTimeSeriesPlan = (CreateTimeSeriesPlan) plan;
-        createTimeseries(createTimeSeriesPlan, createTimeSeriesPlan.getTagOffset());
-        break;
-      case CREATE_ALIGNED_TIMESERIES:
-        CreateAlignedTimeSeriesPlan createAlignedTimeSeriesPlan =
-            (CreateAlignedTimeSeriesPlan) plan;
-        createAlignedTimeSeries(createAlignedTimeSeriesPlan);
-        break;
-      case DELETE_TIMESERIES:
-        DeleteTimeSeriesPlan deleteTimeSeriesPlan = (DeleteTimeSeriesPlan) plan;
-        for (PartialPath path : deleteTimeSeriesPlan.getPaths()) {
-          deleteTimeseries(path);
-        }
-        break;
-      case SET_STORAGE_GROUP:
-        SetStorageGroupPlan setStorageGroupPlan = (SetStorageGroupPlan) plan;
-        setStorageGroup(setStorageGroupPlan.getPath());
-        break;
-      case DELETE_STORAGE_GROUP:
-        DeleteStorageGroupPlan deleteStorageGroupPlan = (DeleteStorageGroupPlan) plan;
-        deleteStorageGroups(deleteStorageGroupPlan.getPaths());
-        break;
-      case TTL:
-        SetTTLPlan setTTLPlan = (SetTTLPlan) plan;
-        setTTL(setTTLPlan.getStorageGroup(), setTTLPlan.getDataTTL());
-        break;
-      case CHANGE_ALIAS:
-        ChangeAliasPlan changeAliasPlan = (ChangeAliasPlan) plan;
-        changeAlias(changeAliasPlan.getPath(), changeAliasPlan.getAlias());
-        break;
-      case CREATE_TEMPLATE:
-        CreateTemplatePlan createTemplatePlan = (CreateTemplatePlan) plan;
-        createSchemaTemplate(createTemplatePlan);
-        break;
-      case DROP_TEMPLATE:
-        DropTemplatePlan dropTemplatePlan = (DropTemplatePlan) plan;
-        dropSchemaTemplate(dropTemplatePlan);
-        break;
-      case APPEND_TEMPLATE:
-        AppendTemplatePlan appendTemplatePlan = (AppendTemplatePlan) plan;
-        appendSchemaTemplate(appendTemplatePlan);
-        break;
-      case PRUNE_TEMPLATE:
-        PruneTemplatePlan pruneTemplatePlan = (PruneTemplatePlan) plan;
-        pruneSchemaTemplate(pruneTemplatePlan);
-        break;
-      case SET_TEMPLATE:
-        SetTemplatePlan setTemplatePlan = (SetTemplatePlan) plan;
-        setSchemaTemplate(setTemplatePlan);
-        break;
-      case ACTIVATE_TEMPLATE:
-        ActivateTemplatePlan activateTemplatePlan = (ActivateTemplatePlan) plan;
-        setUsingSchemaTemplate(activateTemplatePlan);
-        break;
-      case AUTO_CREATE_DEVICE_MNODE:
-        AutoCreateDeviceMNodePlan autoCreateDeviceMNodePlan = (AutoCreateDeviceMNodePlan) plan;
-        autoCreateDeviceMNode(autoCreateDeviceMNodePlan);
-        break;
-      case UNSET_TEMPLATE:
-        UnsetTemplatePlan unsetTemplatePlan = (UnsetTemplatePlan) plan;
-        unsetSchemaTemplate(unsetTemplatePlan);
-        break;
-      default:
-        logger.error("Unrecognizable command {}", plan.getOperatorType());
-    }
-  }
-
-  private void autoCreateDeviceMNode(AutoCreateDeviceMNodePlan plan) throws MetadataException {
-    getBelongedSchemaRegion(plan.getPath()).autoCreateDeviceMNode(plan);
-  }
-  // endregion
-
   // region Interfaces and Implementation for Timeseries operation
   // including create and delete
 
@@ -461,8 +365,7 @@ public class LocalSchemaProcessor {
   public int getAllTimeseriesCount(PartialPath pathPattern, boolean isPrefixMatch)
       throws MetadataException {
     // todo this is for test assistance, refactor this to support massive timeseries
-    if (pathPattern.getFullPath().equals("root.**")
-        && TemplateManager.getInstance().getAllTemplateName().isEmpty()) {
+    if (pathPattern.getFullPath().equals("root.**")) {
       return (int) SchemaStatisticsManager.getInstance().getTotalSeriesNumber();
     }
     int count = 0;
@@ -924,16 +827,6 @@ public class LocalSchemaProcessor {
   public IMeasurementSchema getSeriesSchema(PartialPath fullPath) throws MetadataException {
     return getMeasurementMNode(fullPath).getSchema();
   }
-
-  // attention: this path must be a device node
-  public List<MeasurementPath> getAllMeasurementByDevicePath(PartialPath devicePath)
-      throws PathNotExistException {
-    try {
-      return getBelongedSchemaRegion(devicePath).getAllMeasurementByDevicePath(devicePath);
-    } catch (MetadataException e) {
-      throw new PathNotExistException(devicePath.getFullPath());
-    }
-  }
   // endregion
   // endregion
 
@@ -1243,84 +1136,6 @@ public class LocalSchemaProcessor {
   }
   // endregion
 
-  // region Interfaces and Implementation for Template operations
-  public void createSchemaTemplate(CreateTemplatePlan plan) throws MetadataException {
-    configManager.createSchemaTemplate(plan);
-  }
-
-  public void appendSchemaTemplate(AppendTemplatePlan plan) throws MetadataException {
-    configManager.appendSchemaTemplate(plan);
-  }
-
-  public void pruneSchemaTemplate(PruneTemplatePlan plan) throws MetadataException {
-    configManager.pruneSchemaTemplate(plan);
-  }
-
-  public int countMeasurementsInTemplate(String templateName) throws MetadataException {
-    return configManager.countMeasurementsInTemplate(templateName);
-  }
-
-  /**
-   * @param templateName name of template to check
-   * @param path full path to check
-   * @return if path correspond to a measurement in template
-   * @throws MetadataException
-   */
-  public boolean isMeasurementInTemplate(String templateName, String path)
-      throws MetadataException {
-    return configManager.isMeasurementInTemplate(templateName, path);
-  }
-
-  public boolean isPathExistsInTemplate(String templateName, String path) throws MetadataException {
-    return configManager.isPathExistsInTemplate(templateName, path);
-  }
-
-  public List<String> getMeasurementsInTemplate(String templateName, String path)
-      throws MetadataException {
-    return configManager.getMeasurementsInTemplate(templateName, path);
-  }
-
-  public List<Pair<String, IMeasurementSchema>> getSchemasInTemplate(
-      String templateName, String path) throws MetadataException {
-    return configManager.getSchemasInTemplate(templateName, path);
-  }
-
-  public Set<String> getAllTemplates() {
-    return configManager.getAllTemplates();
-  }
-
-  /**
-   * Get all paths set designated template
-   *
-   * @param templateName designated template name, blank string for any template exists
-   * @return paths set
-   */
-  public Set<String> getPathsSetTemplate(String templateName) throws MetadataException {
-    return configManager.getPathsSetTemplate(templateName);
-  }
-
-  public Set<String> getPathsUsingTemplate(String templateName) throws MetadataException {
-    return configManager.getPathsUsingTemplate(templateName);
-  }
-
-  public void dropSchemaTemplate(DropTemplatePlan plan) throws MetadataException {
-    configManager.dropSchemaTemplate(plan);
-  }
-
-  public synchronized void setSchemaTemplate(SetTemplatePlan plan) throws MetadataException {
-    configManager.setSchemaTemplate(plan);
-  }
-
-  public synchronized void unsetSchemaTemplate(UnsetTemplatePlan plan) throws MetadataException {
-    configManager.unsetSchemaTemplate(plan);
-  }
-
-  public void setUsingSchemaTemplate(ActivateTemplatePlan plan) throws MetadataException {
-    configManager.setUsingSchemaTemplate(plan);
-  }
-
-  // endregion
-
   // region Interfaces for Trigger
 
   public IMNode getMNodeForTrigger(PartialPath fullPath) throws MetadataException {
@@ -1367,14 +1182,5 @@ public class LocalSchemaProcessor {
     }
     return device;
   }
-
-  @TestOnly
-  public Template getTemplate(String templateName) throws MetadataException {
-    try {
-      return TemplateManager.getInstance().getTemplate(templateName);
-    } catch (UndefinedTemplateException e) {
-      throw new MetadataException(e);
-    }
-  }
   // endregion
 }
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/idtable/entry/InsertMeasurementMNode.java b/server/src/main/java/org/apache/iotdb/db/metadata/idtable/entry/InsertMeasurementMNode.java
index 9c246ac2ec..1258bfb3e9 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/idtable/entry/InsertMeasurementMNode.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/idtable/entry/InsertMeasurementMNode.java
@@ -31,7 +31,6 @@ import org.apache.iotdb.db.metadata.mnode.MNodeType;
 import org.apache.iotdb.db.metadata.mnode.container.IMNodeContainer;
 import org.apache.iotdb.db.metadata.mnode.visitor.MNodeVisitor;
 import org.apache.iotdb.db.metadata.mtree.store.disk.cache.CacheEntry;
-import org.apache.iotdb.db.metadata.template.Template;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
 import org.apache.iotdb.tsfile.write.schema.IMeasurementSchema;
 import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
@@ -181,21 +180,6 @@ public class InsertMeasurementMNode implements IMeasurementMNode {
     throw new UnsupportedOperationException("insert measurement mnode doesn't support this method");
   }
 
-  @Override
-  public Template getUpperTemplate() {
-    throw new UnsupportedOperationException("insert measurement mnode doesn't support this method");
-  }
-
-  @Override
-  public Template getSchemaTemplate() {
-    throw new UnsupportedOperationException("insert measurement mnode doesn't support this method");
-  }
-
-  @Override
-  public void setSchemaTemplate(Template schemaTemplate) {
-    throw new UnsupportedOperationException("insert measurement mnode doesn't support this method");
-  }
-
   @Override
   public int getSchemaTemplateId() {
     throw new UnsupportedOperationException("insert measurement mnode doesn't support this method");
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/logfile/MLogWriter.java b/server/src/main/java/org/apache/iotdb/db/metadata/logfile/MLogWriter.java
index 86e15ecde9..f5c3384f18 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/logfile/MLogWriter.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/logfile/MLogWriter.java
@@ -27,25 +27,17 @@ import org.apache.iotdb.db.metadata.mnode.IMNode;
 import org.apache.iotdb.db.metadata.mnode.IMeasurementMNode;
 import org.apache.iotdb.db.metadata.mnode.IStorageGroupMNode;
 import org.apache.iotdb.db.qp.physical.PhysicalPlan;
-import org.apache.iotdb.db.qp.physical.sys.ActivateTemplatePlan;
-import org.apache.iotdb.db.qp.physical.sys.AppendTemplatePlan;
-import org.apache.iotdb.db.qp.physical.sys.AutoCreateDeviceMNodePlan;
 import org.apache.iotdb.db.qp.physical.sys.ChangeAliasPlan;
 import org.apache.iotdb.db.qp.physical.sys.ChangeTagOffsetPlan;
 import org.apache.iotdb.db.qp.physical.sys.CreateAlignedTimeSeriesPlan;
-import org.apache.iotdb.db.qp.physical.sys.CreateTemplatePlan;
 import org.apache.iotdb.db.qp.physical.sys.CreateTimeSeriesPlan;
 import org.apache.iotdb.db.qp.physical.sys.DeleteStorageGroupPlan;
 import org.apache.iotdb.db.qp.physical.sys.DeleteTimeSeriesPlan;
-import org.apache.iotdb.db.qp.physical.sys.DropTemplatePlan;
 import org.apache.iotdb.db.qp.physical.sys.MNodePlan;
 import org.apache.iotdb.db.qp.physical.sys.MeasurementMNodePlan;
-import org.apache.iotdb.db.qp.physical.sys.PruneTemplatePlan;
 import org.apache.iotdb.db.qp.physical.sys.SetStorageGroupPlan;
 import org.apache.iotdb.db.qp.physical.sys.SetTTLPlan;
-import org.apache.iotdb.db.qp.physical.sys.SetTemplatePlan;
 import org.apache.iotdb.db.qp.physical.sys.StorageGroupMNodePlan;
-import org.apache.iotdb.db.qp.physical.sys.UnsetTemplatePlan;
 import org.apache.iotdb.db.utils.writelog.LogWriter;
 import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
@@ -181,34 +173,6 @@ public class MLogWriter implements AutoCloseable {
     putLog(plan);
   }
 
-  public void createSchemaTemplate(CreateTemplatePlan plan) throws IOException {
-    putLog(plan);
-  }
-
-  public void appendSchemaTemplate(AppendTemplatePlan plan) throws IOException {
-    putLog(plan);
-  }
-
-  public void pruneSchemaTemplate(PruneTemplatePlan plan) throws IOException {
-    putLog(plan);
-  }
-
-  public void setSchemaTemplate(SetTemplatePlan plan) throws IOException {
-    putLog(plan);
-  }
-
-  public void unsetSchemaTemplate(UnsetTemplatePlan plan) throws IOException {
-    putLog(plan);
-  }
-
-  public void dropSchemaTemplate(DropTemplatePlan plan) throws IOException {
-    putLog(plan);
-  }
-
-  public void autoCreateDeviceMNode(AutoCreateDeviceMNodePlan plan) throws IOException {
-    putLog(plan);
-  }
-
   public void serializeMNode(IMNode node) throws IOException {
     int childSize = 0;
     if (node.getChildren() != null) {
@@ -239,11 +203,6 @@ public class MLogWriter implements AutoCloseable {
     putLog(plan);
   }
 
-  public void setUsingSchemaTemplate(PartialPath path) throws IOException {
-    ActivateTemplatePlan plan = new ActivateTemplatePlan(path);
-    putLog(plan);
-  }
-
   public synchronized void clear() throws IOException {
     sync();
     logWriter.close();
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/mnode/IMNode.java b/server/src/main/java/org/apache/iotdb/db/metadata/mnode/IMNode.java
index c9e1ce2eb8..a4c4473b8d 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/mnode/IMNode.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/mnode/IMNode.java
@@ -23,7 +23,6 @@ import org.apache.iotdb.db.metadata.logfile.MLogWriter;
 import org.apache.iotdb.db.metadata.mnode.container.IMNodeContainer;
 import org.apache.iotdb.db.metadata.mnode.visitor.MNodeVisitor;
 import org.apache.iotdb.db.metadata.mtree.store.disk.cache.CacheEntry;
-import org.apache.iotdb.db.metadata.template.Template;
 
 import java.io.IOException;
 import java.io.Serializable;
@@ -70,12 +69,6 @@ public interface IMNode extends Serializable {
 
   void setUseTemplate(boolean useTemplate);
 
-  Template getUpperTemplate();
-
-  Template getSchemaTemplate();
-
-  void setSchemaTemplate(Template schemaTemplate);
-
   int getSchemaTemplateId();
 
   void setSchemaTemplateId(int schemaTemplateId);
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/mnode/InternalMNode.java b/server/src/main/java/org/apache/iotdb/db/metadata/mnode/InternalMNode.java
index d9fd415a53..3b34ef08ad 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/mnode/InternalMNode.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/mnode/InternalMNode.java
@@ -22,7 +22,6 @@ import org.apache.iotdb.db.metadata.logfile.MLogWriter;
 import org.apache.iotdb.db.metadata.mnode.container.IMNodeContainer;
 import org.apache.iotdb.db.metadata.mnode.container.MNodeContainers;
 import org.apache.iotdb.db.metadata.mnode.visitor.MNodeVisitor;
-import org.apache.iotdb.db.metadata.template.Template;
 import org.apache.iotdb.db.qp.physical.sys.MNodePlan;
 
 import java.io.IOException;
@@ -55,8 +54,6 @@ public class InternalMNode extends MNode {
    */
   protected int schemaTemplateId = NON_TEMPLATE;
 
-  protected Template schemaTemplate = null;
-
   private volatile boolean useTemplate = false;
 
   /** Constructor of MNode. */
@@ -171,7 +168,6 @@ public class InternalMNode extends MNode {
   public void moveDataToNewMNode(IMNode newMNode) {
     super.moveDataToNewMNode(newMNode);
 
-    newMNode.setSchemaTemplate(schemaTemplate);
     newMNode.setUseTemplate(useTemplate);
     newMNode.setSchemaTemplateId(schemaTemplateId);
 
@@ -194,24 +190,6 @@ public class InternalMNode extends MNode {
     this.children = children;
   }
 
-  /**
-   * get upper template of this node, remember we get nearest template alone this node to root
-   *
-   * @return upper template
-   */
-  @Override
-  public Template getUpperTemplate() {
-    IMNode cur = this;
-    while (cur != null) {
-      if (cur.getSchemaTemplate() != null) {
-        return cur.getSchemaTemplate();
-      }
-      cur = cur.getParent();
-    }
-
-    return null;
-  }
-
   @Override
   public int getSchemaTemplateId() {
     return schemaTemplateId >= -1 ? schemaTemplateId : -schemaTemplateId - 2;
@@ -258,16 +236,6 @@ public class InternalMNode extends MNode {
     return isConfig ? MNodeType.SG_INTERNAL : MNodeType.INTERNAL;
   }
 
-  @Override
-  public Template getSchemaTemplate() {
-    return schemaTemplate;
-  }
-
-  @Override
-  public void setSchemaTemplate(Template schemaTemplate) {
-    this.schemaTemplate = schemaTemplate;
-  }
-
   @Override
   public boolean isUseTemplate() {
     return useTemplate;
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/mnode/MeasurementMNode.java b/server/src/main/java/org/apache/iotdb/db/metadata/mnode/MeasurementMNode.java
index 89b9e366a3..30d763c5d7 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/mnode/MeasurementMNode.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/mnode/MeasurementMNode.java
@@ -25,7 +25,6 @@ import org.apache.iotdb.db.metadata.logfile.MLogWriter;
 import org.apache.iotdb.db.metadata.mnode.container.IMNodeContainer;
 import org.apache.iotdb.db.metadata.mnode.container.MNodeContainers;
 import org.apache.iotdb.db.metadata.mnode.visitor.MNodeVisitor;
-import org.apache.iotdb.db.metadata.template.Template;
 import org.apache.iotdb.db.qp.physical.sys.MeasurementMNodePlan;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
 import org.apache.iotdb.tsfile.write.schema.IMeasurementSchema;
@@ -220,22 +219,6 @@ public class MeasurementMNode extends MNode implements IMeasurementMNode {
     // Do nothing
   }
 
-  @Override
-  public Template getUpperTemplate() {
-    return parent.getUpperTemplate();
-  }
-
-  @Override
-  public Template getSchemaTemplate() {
-    MeasurementMNode.logger.warn(
-        "current node {} is a MeasurementMNode, can not get Schema Template", name);
-    throw new RuntimeException(
-        String.format("current node %s is a MeasurementMNode, can not get Schema Template", name));
-  }
-
-  @Override
-  public void setSchemaTemplate(Template schemaTemplate) {}
-
   @Override
   public int getSchemaTemplateId() {
     MeasurementMNode.logger.warn(
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/IMTreeBelowSG.java b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/IMTreeBelowSG.java
index d59e2e82d4..95e7fd58cf 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/IMTreeBelowSG.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/IMTreeBelowSG.java
@@ -336,72 +336,6 @@ public interface IMTreeBelowSG {
   List<IMeasurementMNode> getMatchedMeasurementMNode(PartialPath pathPattern)
       throws MetadataException;
 
-  /**
-   * check whether there is template on given path and the subTree has template return true,
-   * otherwise false
-   */
-  void checkTemplateOnPath(PartialPath path) throws MetadataException;
-
-  /**
-   * Check route 1: If template has no direct measurement, just pass the check.
-   *
-   * <p>Check route 2: If template has direct measurement and mounted node is Internal, it should be
-   * set to Entity.
-   *
-   * <p>Check route 3: If template has direct measurement and mounted node is Entity,
-   *
-   * <ul>
-   *   <p>route 3.1: mounted node has no measurement child, then its alignment will be set as the
-   *   template.
-   *   <p>route 3.2: mounted node has measurement child, then alignment of it and template should be
-   *   identical, otherwise cast a exception.
-   * </ul>
-   *
-   * @return return the node competent to be mounted.
-   */
-  IMNode checkTemplateAlignmentWithMountedNode(IMNode mountedNode, Template template)
-      throws MetadataException;
-
-  void checkIsTemplateCompatibleWithChild(IMNode node, Template template) throws MetadataException;
-
-  void checkTemplateInUseOnLowerNode(IMNode node) throws MetadataException;
-
-  /**
-   * Check that each node set with tarTemplate and its descendants have overlapping nodes with
-   * appending measurements
-   */
-  boolean isTemplateAppendable(Template tarTemplate, List<String> appendMeasurements)
-      throws MetadataException;
-
-  /**
-   * Note that template and MTree cannot have overlap paths.
-   *
-   * @return true iff path corresponding to a measurement inside a template, whether using or not.
-   */
-  boolean isPathExistsWithinTemplate(PartialPath path) throws MetadataException;
-
-  /**
-   * Check measurement path and return the mounted node index on path. The node could have not
-   * created yet. The result is used for getDeviceNodeWithAutoCreate, which return corresponding
-   * IMNode on MTree.
-   *
-   * @return index on full path of the node which matches all measurements path with its
-   *     upperTemplate.
-   */
-  int getMountedNodeIndexOnMeasurementPath(PartialPath devicePath, String[] measurements)
-      throws MetadataException;
-
-  List<String> getPathsSetOnTemplate(String templateName) throws MetadataException;
-
-  List<String> getPathsUsingTemplate(String templateName) throws MetadataException;
-
-  /**
-   * Get template name on give path if any node of it has been set a template
-   *
-   * @return null if no template has been set on path
-   */
-  String getTemplateOnPath(PartialPath path) throws MetadataException;
-
   void activateTemplate(PartialPath activatePath, Template template) throws MetadataException;
 
   List<String> getPathsUsingTemplate(PartialPath pathPattern, int templateId)
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTreeBelowSGCachedImpl.java b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTreeBelowSGCachedImpl.java
index 075e701e2f..154755e2c3 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTreeBelowSGCachedImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTreeBelowSGCachedImpl.java
@@ -24,7 +24,6 @@ import org.apache.iotdb.commons.exception.IllegalPathException;
 import org.apache.iotdb.commons.exception.MetadataException;
 import org.apache.iotdb.commons.path.MeasurementPath;
 import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.commons.utils.PathUtils;
 import org.apache.iotdb.db.exception.metadata.AliasAlreadyExistException;
 import org.apache.iotdb.db.exception.metadata.AlignedTimeseriesException;
 import org.apache.iotdb.db.exception.metadata.MNodeTypeMismatchException;
@@ -44,7 +43,6 @@ import org.apache.iotdb.db.metadata.mnode.InternalMNode;
 import org.apache.iotdb.db.metadata.mnode.MeasurementMNode;
 import org.apache.iotdb.db.metadata.mnode.iterator.IMNodeIterator;
 import org.apache.iotdb.db.metadata.mtree.store.CachedMTreeStore;
-import org.apache.iotdb.db.metadata.mtree.traverser.collector.CollectorTraverser;
 import org.apache.iotdb.db.metadata.mtree.traverser.collector.EntityCollector;
 import org.apache.iotdb.db.metadata.mtree.traverser.collector.MNodeCollector;
 import org.apache.iotdb.db.metadata.mtree.traverser.collector.MeasurementCollector;
@@ -69,12 +67,9 @@ import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
 
 import java.io.File;
 import java.io.IOException;
-import java.util.ArrayDeque;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.Comparator;
-import java.util.Deque;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedList;
@@ -89,8 +84,6 @@ import java.util.stream.Stream;
 
 import static java.util.stream.Collectors.toList;
 import static org.apache.iotdb.commons.conf.IoTDBConstant.ONE_LEVEL_PATH_WILDCARD;
-import static org.apache.iotdb.commons.conf.IoTDBConstant.PATH_SEPARATOR;
-import static org.apache.iotdb.db.metadata.MetadataConstant.ALL_RESULT_NODES;
 import static org.apache.iotdb.db.metadata.lastCache.LastCacheManager.getLastTimeStamp;
 
 /**
@@ -235,17 +228,13 @@ public class MTreeBelowSGCachedImpl implements IMTreeBelowSG {
     }
     MetaFormatUtils.checkTimeseries(path);
     PartialPath devicePath = path.getDevicePath();
-    Pair<IMNode, Template> pair = checkAndAutoCreateInternalPath(devicePath);
-    IMNode deviceParent = pair.left;
-    Template upperTemplate = pair.right;
+    IMNode deviceParent = checkAndAutoCreateInternalPath(devicePath);
 
     try {
       // synchronize check and add, we need addChild and add Alias become atomic operation
       // only write on mtree will be synchronized
       synchronized (this) {
-        pair = checkAndAutoCreateDeviceNode(devicePath.getTailNode(), deviceParent, upperTemplate);
-        IMNode device = pair.left;
-        upperTemplate = pair.right;
+        IMNode device = checkAndAutoCreateDeviceNode(devicePath.getTailNode(), deviceParent);
 
         try {
           MetaFormatUtils.checkTimeseriesProps(path.getFullPath(), props);
@@ -260,12 +249,6 @@ public class MTreeBelowSGCachedImpl implements IMTreeBelowSG {
             throw new PathAlreadyExistException(path.getFullPath());
           }
 
-          if (upperTemplate != null
-              && (upperTemplate.getDirectNode(leafName) != null
-                  || upperTemplate.getDirectNode(alias) != null)) {
-            throw new TemplateImcompatibeException(path.getFullPath(), upperTemplate.getName());
-          }
-
           if (device.isEntity() && device.getAsEntityMNode().isAligned()) {
             throw new AlignedTimeseriesException(
                 "timeseries under this entity is aligned, please use createAlignedTimeseries or change entity.",
@@ -327,17 +310,13 @@ public class MTreeBelowSGCachedImpl implements IMTreeBelowSG {
       throws MetadataException {
     List<IMeasurementMNode> measurementMNodeList = new ArrayList<>();
     MetaFormatUtils.checkSchemaMeasurementNames(measurements);
-    Pair<IMNode, Template> pair = checkAndAutoCreateInternalPath(devicePath);
-    IMNode deviceParent = pair.left;
-    Template upperTemplate = pair.right;
+    IMNode deviceParent = checkAndAutoCreateInternalPath(devicePath);
 
     try {
       // synchronize check and add, we need addChild operation be atomic.
       // only write operations on mtree will be synchronized
       synchronized (this) {
-        pair = checkAndAutoCreateDeviceNode(devicePath.getTailNode(), deviceParent, upperTemplate);
-        IMNode device = pair.left;
-        upperTemplate = pair.right;
+        IMNode device = checkAndAutoCreateDeviceNode(devicePath.getTailNode(), deviceParent);
 
         try {
           for (int i = 0; i < measurements.size(); i++) {
@@ -353,15 +332,6 @@ public class MTreeBelowSGCachedImpl implements IMTreeBelowSG {
             }
           }
 
-          if (upperTemplate != null) {
-            for (String measurement : measurements) {
-              if (upperTemplate.getDirectNode(measurement) != null) {
-                throw new TemplateImcompatibeException(
-                    devicePath.concatNode(measurement).getFullPath(), upperTemplate.getName());
-              }
-            }
-          }
-
           if (device.isEntity() && !device.getAsEntityMNode().isAligned()) {
             throw new AlignedTimeseriesException(
                 "Timeseries under this entity is not aligned, please use createTimeseries or change entity.",
@@ -470,27 +440,21 @@ public class MTreeBelowSGCachedImpl implements IMTreeBelowSG {
     }
   }
 
-  private Pair<IMNode, Template> checkAndAutoCreateInternalPath(PartialPath devicePath)
-      throws MetadataException {
+  private IMNode checkAndAutoCreateInternalPath(PartialPath devicePath) throws MetadataException {
     String[] nodeNames = devicePath.getNodes();
     MetaFormatUtils.checkTimeseries(devicePath);
     if (nodeNames.length == levelOfSG + 1) {
-      return new Pair<>(null, null);
+      return null;
     }
     IMNode cur = storageGroupMNode;
     IMNode child;
     String childName;
-    Template upperTemplate = cur.getSchemaTemplate();
     try {
       // e.g, path = root.sg.d1.s1,  create internal nodes and set cur to sg node, parent of d1
       for (int i = levelOfSG + 1; i < nodeNames.length - 1; i++) {
         childName = nodeNames[i];
         child = store.getChild(cur, childName);
         if (child == null) {
-          if (upperTemplate != null && upperTemplate.getDirectNode(childName) != null) {
-            throw new TemplateImcompatibeException(
-                devicePath.getFullPath(), upperTemplate.getName(), childName);
-          }
           child = store.addChild(cur, childName, new InternalMNode(cur, childName));
         }
         cur = child;
@@ -498,33 +462,23 @@ public class MTreeBelowSGCachedImpl implements IMTreeBelowSG {
         if (cur.isMeasurement()) {
           throw new PathAlreadyExistException(cur.getFullPath());
         }
-
-        if (cur.getSchemaTemplate() != null) {
-          upperTemplate = cur.getSchemaTemplate();
-        }
       }
       pinMNode(cur);
-      return new Pair<>(cur, upperTemplate);
+      return cur;
     } finally {
       unPinPath(cur);
     }
   }
 
-  private Pair<IMNode, Template> checkAndAutoCreateDeviceNode(
-      String deviceName, IMNode deviceParent, Template upperTemplate) throws MetadataException {
+  private IMNode checkAndAutoCreateDeviceNode(String deviceName, IMNode deviceParent)
+      throws MetadataException {
     if (deviceParent == null) {
       // device is sg
       pinMNode(storageGroupMNode);
-      return new Pair<>(storageGroupMNode, null);
+      return storageGroupMNode;
     }
     IMNode device = store.getChild(deviceParent, deviceName);
     if (device == null) {
-      if (upperTemplate != null && upperTemplate.getDirectNode(deviceName) != null) {
-        throw new TemplateImcompatibeException(
-            deviceParent.getPartialPath().concatNode(deviceName).getFullPath(),
-            upperTemplate.getName(),
-            deviceName);
-      }
       device =
           store.addChild(deviceParent, deviceName, new InternalMNode(deviceParent, deviceName));
     }
@@ -532,12 +486,7 @@ public class MTreeBelowSGCachedImpl implements IMTreeBelowSG {
     if (device.isMeasurement()) {
       throw new PathAlreadyExistException(device.getFullPath());
     }
-
-    if (device.getSchemaTemplate() != null) {
-      upperTemplate = device.getSchemaTemplate();
-    }
-
-    return new Pair<>(device, upperTemplate);
+    return device;
   }
 
   /**
@@ -553,10 +502,6 @@ public class MTreeBelowSGCachedImpl implements IMTreeBelowSG {
       throw new IllegalPathException(path.getFullPath());
     }
 
-    if (isPathExistsWithinTemplate(path)) {
-      throw new MetadataException("Cannot delete a timeseries inside a template: " + path);
-    }
-
     IMeasurementMNode deletedNode = getMeasurementMNode(path);
     IEntityMNode parent = deletedNode.getParent();
     // delete the last node of path
@@ -622,7 +567,6 @@ public class MTreeBelowSGCachedImpl implements IMTreeBelowSG {
     try {
       return !IoTDBConstant.PATH_ROOT.equals(node.getName())
           && !node.isMeasurement()
-          && node.getSchemaTemplate() == null
           && !node.isUseTemplate()
           && !iterator.hasNext();
     } finally {
@@ -686,20 +630,13 @@ public class MTreeBelowSGCachedImpl implements IMTreeBelowSG {
     MetaFormatUtils.checkTimeseries(deviceId);
     IMNode cur = storageGroupMNode;
     IMNode child;
-    Template upperTemplate = cur.getSchemaTemplate();
     try {
       for (int i = levelOfSG + 1; i < nodeNames.length; i++) {
         child = store.getChild(cur, nodeNames[i]);
         if (child == null) {
-          if (cur.isUseTemplate() && upperTemplate.getDirectNode(nodeNames[i]) != null) {
-            throw new PathAlreadyExistException(
-                cur.getPartialPath().concatNode(nodeNames[i]).getFullPath());
-          }
           child = store.addChild(cur, nodeNames[i], new InternalMNode(cur, nodeNames[i]));
         }
         cur = child;
-        // update upper template
-        upperTemplate = cur.getSchemaTemplate() == null ? upperTemplate : cur.getSchemaTemplate();
       }
       pinMNode(cur);
       return cur;
@@ -733,48 +670,22 @@ public class MTreeBelowSGCachedImpl implements IMTreeBelowSG {
     String[] nodeNames = path.getNodes();
     IMNode cur = storageGroupMNode;
     IMNode child;
-    Template upperTemplate = cur.getSchemaTemplate();
-    boolean isInTemplate = false;
     try {
       for (int i = levelOfSG + 1; i < nodeNames.length; i++) {
-        if (isInTemplate) {
-          child = cur.getChild(nodeNames[i]);
-          if (child == null) {
-            return false;
-          }
+        child = store.getChild(cur, nodeNames[i]);
+        if (child == null) {
+          return false;
+        } else {
           if (child.isMeasurement()) {
+            cur = child;
             return i == nodeNames.length - 1;
           }
-        } else {
-          upperTemplate = cur.getSchemaTemplate() == null ? upperTemplate : cur.getSchemaTemplate();
-          child = store.getChild(cur, nodeNames[i]);
-          if (child == null) {
-
-            if (upperTemplate == null
-                || !cur.isUseTemplate()
-                || upperTemplate.getDirectNode(nodeNames[i]) == null) {
-              return false;
-            }
-            child = upperTemplate.getDirectNode(nodeNames[i]);
-            isInTemplate = true;
-            unPinPath(cur);
-            if (child.isMeasurement()) {
-              return i == nodeNames.length - 1;
-            }
-          } else {
-            if (child.isMeasurement()) {
-              cur = child;
-              return i == nodeNames.length - 1;
-            }
-          }
         }
         cur = child;
       }
       return true;
     } finally {
-      if (!isInTemplate) {
-        unPinPath(cur);
-      }
+      unPinPath(cur);
     }
   }
 
@@ -1197,53 +1108,24 @@ public class MTreeBelowSGCachedImpl implements IMTreeBelowSG {
     String[] nodes = path.getNodes();
     IMNode cur = storageGroupMNode;
     IMNode next;
-    Template upperTemplate = cur.getSchemaTemplate();
-    boolean isInTemplate = false;
     try {
       for (int i = levelOfSG + 1; i < nodes.length; i++) {
-        if (isInTemplate) {
-          next = cur.getChild(nodes[i]);
-          if (next == null) {
+        next = store.getChild(cur, nodes[i]);
+        if (next == null) {
+          throw new PathNotExistException(path.getFullPath(), true);
+        } else if (next.isMeasurement()) {
+          if (i == nodes.length - 1) {
+            return next;
+          } else {
             throw new PathNotExistException(path.getFullPath(), true);
-          } else if (next.isMeasurement()) {
-            if (i == nodes.length - 1) {
-              return next;
-            } else {
-              throw new PathNotExistException(path.getFullPath(), true);
-            }
-          }
-        } else {
-          if (cur.getSchemaTemplate() != null) {
-            upperTemplate = cur.getSchemaTemplate();
-          }
-          next = store.getChild(cur, nodes[i]);
-          if (next == null) {
-            if (upperTemplate == null
-                || !cur.isUseTemplate()
-                || upperTemplate.getDirectNode(nodes[i]) == null) {
-              throw new PathNotExistException(path.getFullPath(), true);
-            }
-            next = upperTemplate.getDirectNode(nodes[i]);
-            isInTemplate = true;
-            unPinPath(cur);
-          } else if (next.isMeasurement()) {
-            if (i == nodes.length - 1) {
-              return next;
-            } else {
-              throw new PathNotExistException(path.getFullPath(), true);
-            }
           }
         }
         cur = next;
       }
-      if (!isInTemplate) {
-        pinMNode(cur);
-      }
+      pinMNode(cur);
       return cur;
     } finally {
-      if (!isInTemplate) {
-        unPinPath(cur);
-      }
+      unPinPath(cur);
     }
   }
 
@@ -1346,461 +1228,6 @@ public class MTreeBelowSGCachedImpl implements IMTreeBelowSG {
   // endregion
 
   // region Interfaces and Implementation for Template check and query
-  /**
-   * check whether there is template on given path and the subTree has template return true,
-   * otherwise false
-   */
-  @Override
-  public void checkTemplateOnPath(PartialPath path) throws MetadataException {
-    String[] nodeNames = path.getNodes();
-    IMNode cur = storageGroupMNode;
-    IMNode child;
-
-    if (cur.getSchemaTemplate() != null) {
-      throw new MetadataException("Template already exists on " + cur.getFullPath());
-    }
-
-    try {
-      for (int i = levelOfSG + 1; i < nodeNames.length; i++) {
-        child = store.getChild(cur, nodeNames[i]);
-        if (child == null) {
-          return;
-        }
-        cur = child;
-        if (cur.getSchemaTemplate() != null) {
-          throw new MetadataException("Template already exists on " + cur.getFullPath());
-        }
-        if (cur.isMeasurement()) {
-          return;
-        }
-      }
-
-      checkTemplateOnSubtree(cur);
-    } finally {
-      unPinPath(cur);
-    }
-  }
-
-  /**
-   * Check route 1: If template has no direct measurement, just pass the check.
-   *
-   * <p>Check route 2: If template has direct measurement and mounted node is Internal, it should be
-   * set to Entity.
-   *
-   * <p>Check route 3: If template has direct measurement and mounted node is Entity,
-   *
-   * <ul>
-   *   <p>route 3.1: mounted node has no measurement child, then its alignment will be set as the
-   *   template.
-   *   <p>route 3.2: mounted node has measurement child, then alignment of it and template should be
-   *   identical, otherwise cast a exception.
-   * </ul>
-   *
-   * @return return the node competent to be mounted.
-   */
-  @Override
-  public IMNode checkTemplateAlignmentWithMountedNode(IMNode mountedNode, Template template)
-      throws MetadataException {
-    boolean hasDirectMeasurement = false;
-    for (IMNode child : template.getDirectNodes()) {
-      if (child.isMeasurement()) {
-        hasDirectMeasurement = true;
-      }
-    }
-    if (!hasDirectMeasurement) {
-      return mountedNode;
-    }
-    if (!mountedNode.isEntity()) {
-      return setToEntity(mountedNode);
-    } else {
-      IMNode child;
-      IMNodeIterator iterator = store.getChildrenIterator(mountedNode);
-      try {
-        while (iterator.hasNext()) {
-          child = iterator.next();
-          unPinMNode(child);
-          if (child.isMeasurement()) {
-            if (template.isDirectAligned() != mountedNode.getAsEntityMNode().isAligned()) {
-              throw new MetadataException(
-                  "Template and mounted node has different alignment: "
-                      + template.getName()
-                      + mountedNode.getFullPath());
-            } else {
-              return mountedNode;
-            }
-          }
-        }
-      } finally {
-        iterator.close();
-      }
-
-      mountedNode.getAsEntityMNode().setAligned(template.isDirectAligned());
-      updateMNode(mountedNode);
-    }
-    return mountedNode;
-  }
-
-  // traverse  all the  descendant of the given path node
-  private void checkTemplateOnSubtree(IMNode node) throws MetadataException {
-    if (node.isMeasurement()) {
-      return;
-    }
-    IMNode child;
-    IMNodeIterator iterator = store.getChildrenIterator(node);
-    try {
-      while (iterator.hasNext()) {
-        child = iterator.next();
-        try {
-          if (child.isMeasurement()) {
-            continue;
-          }
-          if (child.getSchemaTemplate() != null) {
-            throw new MetadataException("Template already exists on " + child.getFullPath());
-          }
-          checkTemplateOnSubtree(child);
-        } finally {
-          unPinMNode(child);
-        }
-      }
-    } finally {
-      iterator.close();
-    }
-  }
-
-  @Override
-  public void checkIsTemplateCompatibleWithChild(IMNode node, Template template)
-      throws MetadataException {
-    for (String measurementPath : template.getSchemaMap().keySet()) {
-      String directNodeName = PathUtils.splitPathToDetachedNodes(measurementPath)[0];
-      if (store.hasChild(node, directNodeName)) {
-        throw new MetadataException(
-            "Node name "
-                + directNodeName
-                + " in template has conflict with node's child "
-                + (node.getFullPath() + "." + directNodeName));
-      }
-    }
-  }
-
-  @Override
-  public void checkTemplateInUseOnLowerNode(IMNode node) throws MetadataException {
-    if (node.isMeasurement()) {
-      return;
-    }
-    IMNode child;
-    IMNodeIterator iterator = store.getChildrenIterator(node);
-    try {
-      while (iterator.hasNext()) {
-        child = iterator.next();
-        try {
-          if (child.isMeasurement()) {
-            continue;
-          }
-          if (child.isUseTemplate()) {
-            throw new TemplateIsInUseException(child.getFullPath());
-          }
-          checkTemplateInUseOnLowerNode(child);
-        } finally {
-          unPinMNode(child);
-        }
-      }
-    } finally {
-      iterator.close();
-    }
-  }
-
-  /**
-   * Check that each node set with tarTemplate and its descendants have overlapping nodes with
-   * appending measurements
-   */
-  @Override
-  public boolean isTemplateAppendable(Template tarTemplate, List<String> appendMeasurements)
-      throws MetadataException {
-    List<String> setPaths = getPathsSetOnTemplate(tarTemplate.getName());
-    if (setPaths.size() == 0) {
-      return true;
-    }
-    Deque<IMNode> setNodes = new ArrayDeque<>();
-    try {
-      for (String path : setPaths) {
-        setNodes.add(getNodeByPath(new PartialPath(path)));
-      }
-      // since overlap of template and MTree is not allowed, it is sufficient to check on the first
-      // node
-      Set<String> overlapSet = new HashSet<>();
-      for (String path : appendMeasurements) {
-        overlapSet.add(PathUtils.splitPathToDetachedNodes(path)[0]);
-      }
-
-      while (setNodes.size() != 0) {
-        IMNode cur = setNodes.pop();
-        try {
-          IMNodeIterator iterator = store.getChildrenIterator(cur);
-          try {
-            IMNode child;
-            while (iterator.hasNext()) {
-              child = iterator.next();
-              if (overlapSet.contains(child.getName())) {
-                unPinMNode(child);
-                return false;
-              }
-              if (!child.isMeasurement()) {
-                setNodes.push(child);
-              } else {
-                unPinMNode(child);
-              }
-            }
-          } finally {
-            iterator.close();
-          }
-        } finally {
-          unPinMNode(cur);
-        }
-      }
-      return true;
-    } finally {
-      while (!setNodes.isEmpty()) {
-        unPinMNode(setNodes.pop());
-      }
-    }
-  }
-
-  /**
-   * Note that template and MTree cannot have overlap paths.
-   *
-   * @return true iff path corresponding to a measurement inside a template, whether using or not.
-   */
-  @Override
-  public boolean isPathExistsWithinTemplate(PartialPath path) throws MetadataException {
-    String[] pathNodes = path.getNodes();
-    IMNode cur = storageGroupMNode;
-    IMNode child;
-    Template upperTemplate = cur.getUpperTemplate();
-    try {
-      for (int i = levelOfSG + 1; i < pathNodes.length; i++) {
-        child = store.getChild(cur, pathNodes[i]);
-        if (child != null) {
-          cur = child;
-          if (cur.isMeasurement()) {
-            return false;
-          }
-          upperTemplate = cur.getSchemaTemplate() == null ? upperTemplate : cur.getSchemaTemplate();
-        } else {
-          if (upperTemplate != null) {
-            String suffixPath =
-                new PartialPath(Arrays.copyOfRange(pathNodes, i, pathNodes.length)).toString();
-            // has template, whether match
-            return upperTemplate.hasSchema(suffixPath);
-          } else {
-            // no child and no template
-            return false;
-          }
-        }
-      }
-      return false;
-    } finally {
-      unPinPath(cur);
-    }
-  }
-
-  /**
-   * Check measurement path and return the mounted node index on path. The node could have not
-   * created yet. The result is used for getDeviceNodeWithAutoCreate, which return corresponding
-   * IMNode on MTree.
-   *
-   * @return index on full path of the node which matches all measurements path with its
-   *     upperTemplate.
-   */
-  public int getMountedNodeIndexOnMeasurementPath(PartialPath devicePath, String[] measurements)
-      throws MetadataException {
-    String[] nodes = devicePath.getNodes();
-    IMNode cur = storageGroupMNode;
-    IMNode child;
-    Template upperTemplate = cur.getSchemaTemplate();
-    int index = levelOfSG + 1;
-    boolean attemptToUseTemplate = false;
-
-    try {
-      // If there are nodes of target path on MTree, use it as possible.
-      for (; index < nodes.length; index++) {
-        upperTemplate = cur.getSchemaTemplate() != null ? cur.getSchemaTemplate() : upperTemplate;
-        child = store.getChild(cur, nodes[index]);
-        if (child == null) {
-          if (upperTemplate == null) {
-            // no matched child, no template, need to create device node as logical device path
-            return nodes.length;
-          } else {
-            attemptToUseTemplate = true;
-            break;
-          }
-        } else {
-          // has child on MTree
-          cur = child;
-        }
-      }
-    } finally {
-      if (index > levelOfSG + 1) {
-        unPinPath(cur);
-      }
-    }
-
-    if (!attemptToUseTemplate) {
-      // all nodes on path exist in MTree, device node should be the penultimate one
-      return nodes.length;
-    }
-
-    // The resting part of target path not exists on MTree, thus try to use template.
-    for (; index < nodes.length; index++) {
-      int fullPathLength = nodes.length - index + 1;
-      String[] suffixNodes = new String[fullPathLength];
-      System.arraycopy(nodes, index, suffixNodes, 0, nodes.length - index);
-      boolean hasAllMeasurements = true;
-
-      for (String measurement : measurements) {
-        // for this fullPath, cur is the last node on MTree
-        // since upperTemplate exists, need to find the matched suffix path of fullPath and
-        // template
-        suffixNodes[fullPathLength - 1] = measurement;
-        String suffixPath = String.join(String.valueOf(PATH_SEPARATOR), suffixNodes);
-
-        if (upperTemplate.hasSchema(suffixPath)) {
-          continue;
-        }
-
-        // if suffix doesn't match, but first node name matched, it's an overlap with template
-        // cast exception for now
-        if (upperTemplate.getDirectNode(nodes[index]) != null) {
-          throw new TemplateImcompatibeException(
-              devicePath.concatNode(measurement).getFullPath(),
-              upperTemplate.getName(),
-              nodes[index]);
-        }
-
-        hasAllMeasurements = false;
-      }
-
-      if (hasAllMeasurements) {
-        return index - 1;
-      }
-    }
-
-    return nodes.length;
-  }
-
-  @Override
-  public List<String> getPathsSetOnTemplate(String templateName) throws MetadataException {
-    List<String> resSet = new ArrayList<>();
-    CollectorTraverser<Set<String>> setTemplatePaths =
-        new CollectorTraverser<Set<String>>(
-            storageGroupMNode, new PartialPath(ALL_RESULT_NODES), store) {
-          @Override
-          protected boolean processInternalMatchedMNode(IMNode node, int idx, int level) {
-            // will never get here, implement for placeholder
-            return false;
-          }
-
-          @Override
-          protected boolean processFullMatchedMNode(IMNode node, int idx, int level)
-              throws MetadataException {
-            // shall not traverse nodes inside template
-            if (!node.getPartialPath().equals(getCurrentPartialPath(node))) {
-              return true;
-            }
-
-            // if node not set template, go on traversing
-            if (node.getSchemaTemplate() != null) {
-              // if set template, and equals to target or target for all, add to result
-              if (templateName.equals(ONE_LEVEL_PATH_WILDCARD)
-                  || templateName.equals(node.getUpperTemplate().getName())) {
-                resSet.add(node.getFullPath());
-              }
-              // descendants of the node cannot set another template, exit from this branch
-              return true;
-            }
-            return false;
-          }
-        };
-    setTemplatePaths.traverse();
-    return resSet;
-  }
-
-  @Override
-  public List<String> getPathsUsingTemplate(String templateName) throws MetadataException {
-    List<String> result = new ArrayList<>();
-
-    CollectorTraverser<Set<String>> usingTemplatePaths =
-        new CollectorTraverser<Set<String>>(
-            storageGroupMNode, new PartialPath(ALL_RESULT_NODES), store) {
-          @Override
-          protected boolean processInternalMatchedMNode(IMNode node, int idx, int level) {
-            // will never get here, implement for placeholder
-            return false;
-          }
-
-          @Override
-          protected boolean processFullMatchedMNode(IMNode node, int idx, int level) {
-            // shall not traverse nodes inside template
-            if (!node.getPartialPath().equals(getCurrentPartialPath(node))) {
-              return true;
-            }
-
-            if (node.getUpperTemplate() != null) {
-              // this node and its descendants are set other template, exit from this branch
-              if (!templateName.equals(ONE_LEVEL_PATH_WILDCARD)
-                  && !templateName.equals(node.getUpperTemplate().getName())) {
-                return true;
-              }
-
-              // descendants of this node may be using template too
-              if (node.isUseTemplate()) {
-                result.add(node.getFullPath());
-              }
-            }
-            return false;
-          }
-        };
-
-    usingTemplatePaths.traverse();
-    return result;
-  }
-
-  /**
-   * Get template name on give path if any node of it has been set a template
-   *
-   * @return null if no template has been set on path
-   */
-  @Override
-  public String getTemplateOnPath(PartialPath path) throws MetadataException {
-    String[] pathNodes = path.getNodes();
-    IMNode cur = storageGroupMNode;
-    IMNode child;
-
-    if (cur.getSchemaTemplate() != null) {
-      return cur.getSchemaTemplate().getName();
-    }
-
-    try {
-      for (int i = levelOfSG + 1; i < pathNodes.length; i++) {
-        child = store.getChild(cur, pathNodes[i]);
-        if (child == null) {
-          return null;
-        }
-        cur = child;
-
-        if (cur.isMeasurement()) {
-          return null;
-        }
-
-        if (cur.getSchemaTemplate() != null) {
-          return cur.getSchemaTemplate().getName();
-        }
-      }
-
-      return null;
-    } finally {
-      unPinPath(cur);
-    }
-  }
 
   @Override
   public void activateTemplate(PartialPath activatePath, Template template)
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTreeBelowSGMemoryImpl.java b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTreeBelowSGMemoryImpl.java
index 4b2e3b359e..436beb6058 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTreeBelowSGMemoryImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTreeBelowSGMemoryImpl.java
@@ -24,7 +24,6 @@ import org.apache.iotdb.commons.exception.IllegalPathException;
 import org.apache.iotdb.commons.exception.MetadataException;
 import org.apache.iotdb.commons.path.MeasurementPath;
 import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.commons.utils.PathUtils;
 import org.apache.iotdb.db.exception.metadata.AliasAlreadyExistException;
 import org.apache.iotdb.db.exception.metadata.AlignedTimeseriesException;
 import org.apache.iotdb.db.exception.metadata.MNodeTypeMismatchException;
@@ -44,7 +43,6 @@ import org.apache.iotdb.db.metadata.mnode.InternalMNode;
 import org.apache.iotdb.db.metadata.mnode.MeasurementMNode;
 import org.apache.iotdb.db.metadata.mnode.iterator.IMNodeIterator;
 import org.apache.iotdb.db.metadata.mtree.store.MemMTreeStore;
-import org.apache.iotdb.db.metadata.mtree.traverser.collector.CollectorTraverser;
 import org.apache.iotdb.db.metadata.mtree.traverser.collector.EntityCollector;
 import org.apache.iotdb.db.metadata.mtree.traverser.collector.MNodeCollector;
 import org.apache.iotdb.db.metadata.mtree.traverser.collector.MeasurementCollector;
@@ -69,12 +67,9 @@ import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
 
 import java.io.File;
 import java.io.IOException;
-import java.util.ArrayDeque;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.Comparator;
-import java.util.Deque;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedList;
@@ -89,8 +84,6 @@ import java.util.stream.Stream;
 
 import static java.util.stream.Collectors.toList;
 import static org.apache.iotdb.commons.conf.IoTDBConstant.ONE_LEVEL_PATH_WILDCARD;
-import static org.apache.iotdb.commons.conf.IoTDBConstant.PATH_SEPARATOR;
-import static org.apache.iotdb.db.metadata.MetadataConstant.ALL_RESULT_NODES;
 import static org.apache.iotdb.db.metadata.lastCache.LastCacheManager.getLastTimeStamp;
 
 /**
@@ -206,16 +199,12 @@ public class MTreeBelowSGMemoryImpl implements IMTreeBelowSG {
     }
     MetaFormatUtils.checkTimeseries(path);
     PartialPath devicePath = path.getDevicePath();
-    Pair<IMNode, Template> pair = checkAndAutoCreateInternalPath(devicePath);
-    IMNode deviceParent = pair.left;
-    Template upperTemplate = pair.right;
+    IMNode deviceParent = checkAndAutoCreateInternalPath(devicePath);
 
     // synchronize check and add, we need addChild and add Alias become atomic operation
     // only write on mtree will be synchronized
     synchronized (this) {
-      pair = checkAndAutoCreateDeviceNode(devicePath.getTailNode(), deviceParent, upperTemplate);
-      IMNode device = pair.left;
-      upperTemplate = pair.right;
+      IMNode device = checkAndAutoCreateDeviceNode(devicePath.getTailNode(), deviceParent);
 
       MetaFormatUtils.checkTimeseriesProps(path.getFullPath(), props);
 
@@ -239,12 +228,6 @@ public class MTreeBelowSGMemoryImpl implements IMTreeBelowSG {
         }
       }
 
-      if (upperTemplate != null
-          && (upperTemplate.getDirectNode(leafName) != null
-              || upperTemplate.getDirectNode(alias) != null)) {
-        throw new TemplateImcompatibeException(path.getFullPath(), upperTemplate.getName());
-      }
-
       if (device.isEntity() && device.getAsEntityMNode().isAligned()) {
         throw new AlignedTimeseriesException(
             "timeseries under this entity is aligned, please use createAlignedTimeseries or change entity.",
@@ -297,16 +280,12 @@ public class MTreeBelowSGMemoryImpl implements IMTreeBelowSG {
       throws MetadataException {
     List<IMeasurementMNode> measurementMNodeList = new ArrayList<>();
     MetaFormatUtils.checkSchemaMeasurementNames(measurements);
-    Pair<IMNode, Template> pair = checkAndAutoCreateInternalPath(devicePath);
-    IMNode deviceParent = pair.left;
-    Template upperTemplate = pair.right;
+    IMNode deviceParent = checkAndAutoCreateInternalPath(devicePath);
 
     // synchronize check and add, we need addChild operation be atomic.
     // only write operations on mtree will be synchronized
     synchronized (this) {
-      pair = checkAndAutoCreateDeviceNode(devicePath.getTailNode(), deviceParent, upperTemplate);
-      IMNode device = pair.left;
-      upperTemplate = pair.right;
+      IMNode device = checkAndAutoCreateDeviceNode(devicePath.getTailNode(), deviceParent);
 
       for (int i = 0; i < measurements.size(); i++) {
         if (device.hasChild(measurements.get(i))) {
@@ -330,15 +309,6 @@ public class MTreeBelowSGMemoryImpl implements IMTreeBelowSG {
         }
       }
 
-      if (upperTemplate != null) {
-        for (String measurement : measurements) {
-          if (upperTemplate.getDirectNode(measurement) != null) {
-            throw new TemplateImcompatibeException(
-                devicePath.concatNode(measurement).getFullPath(), upperTemplate.getName());
-          }
-        }
-      }
-
       if (device.isEntity() && !device.getAsEntityMNode().isAligned()) {
         throw new AlignedTimeseriesException(
             "Timeseries under this entity is not aligned, please use createTimeseries or change entity.",
@@ -374,26 +344,20 @@ public class MTreeBelowSGMemoryImpl implements IMTreeBelowSG {
     }
   }
 
-  private Pair<IMNode, Template> checkAndAutoCreateInternalPath(PartialPath devicePath)
-      throws MetadataException {
+  private IMNode checkAndAutoCreateInternalPath(PartialPath devicePath) throws MetadataException {
     String[] nodeNames = devicePath.getNodes();
     MetaFormatUtils.checkTimeseries(devicePath);
     if (nodeNames.length == levelOfSG + 1) {
-      return new Pair<>(null, null);
+      return null;
     }
     IMNode cur = storageGroupMNode;
     IMNode child;
     String childName;
-    Template upperTemplate = cur.getSchemaTemplate();
     // e.g, path = root.sg.d1.s1,  create internal nodes and set cur to sg node, parent of d1
     for (int i = levelOfSG + 1; i < nodeNames.length - 1; i++) {
       childName = nodeNames[i];
       child = cur.getChild(childName);
       if (child == null) {
-        if (upperTemplate != null && upperTemplate.getDirectNode(childName) != null) {
-          throw new TemplateImcompatibeException(
-              devicePath.getFullPath(), upperTemplate.getName(), childName);
-        }
         child = store.addChild(cur, childName, new InternalMNode(cur, childName));
       }
       cur = child;
@@ -401,29 +365,18 @@ public class MTreeBelowSGMemoryImpl implements IMTreeBelowSG {
       if (cur.isMeasurement()) {
         throw new PathAlreadyExistException(cur.getFullPath());
       }
-
-      if (cur.getSchemaTemplate() != null) {
-        upperTemplate = cur.getSchemaTemplate();
-      }
     }
-    return new Pair<>(cur, upperTemplate);
+    return cur;
   }
 
-  private Pair<IMNode, Template> checkAndAutoCreateDeviceNode(
-      String deviceName, IMNode deviceParent, Template upperTemplate)
-      throws PathAlreadyExistException, TemplateImcompatibeException {
+  private IMNode checkAndAutoCreateDeviceNode(String deviceName, IMNode deviceParent)
+      throws PathAlreadyExistException {
     if (deviceParent == null) {
       // device is sg
-      return new Pair<>(storageGroupMNode, null);
+      return storageGroupMNode;
     }
     IMNode device = store.getChild(deviceParent, deviceName);
     if (device == null) {
-      if (upperTemplate != null && upperTemplate.getDirectNode(deviceName) != null) {
-        throw new TemplateImcompatibeException(
-            deviceParent.getPartialPath().concatNode(deviceName).getFullPath(),
-            upperTemplate.getName(),
-            deviceName);
-      }
       device =
           store.addChild(deviceParent, deviceName, new InternalMNode(deviceParent, deviceName));
     }
@@ -431,12 +384,7 @@ public class MTreeBelowSGMemoryImpl implements IMTreeBelowSG {
     if (device.isMeasurement()) {
       throw new PathAlreadyExistException(device.getFullPath());
     }
-
-    if (device.getSchemaTemplate() != null) {
-      upperTemplate = device.getSchemaTemplate();
-    }
-
-    return new Pair<>(device, upperTemplate);
+    return device;
   }
 
   @Override
@@ -497,10 +445,6 @@ public class MTreeBelowSGMemoryImpl implements IMTreeBelowSG {
       throw new IllegalPathException(path.getFullPath());
     }
 
-    if (isPathExistsWithinTemplate(path)) {
-      throw new MetadataException("Cannot delete a timeseries inside a template: " + path);
-    }
-
     IMeasurementMNode deletedNode = getMeasurementMNode(path);
     IEntityMNode parent = deletedNode.getParent();
     // delete the last node of path
@@ -552,7 +496,6 @@ public class MTreeBelowSGMemoryImpl implements IMTreeBelowSG {
   public boolean isEmptyInternalMNode(IMNode node) {
     return !IoTDBConstant.PATH_ROOT.equals(node.getName())
         && !node.isMeasurement()
-        && node.getSchemaTemplate() == null
         && !node.isUseTemplate()
         && node.getChildren().isEmpty();
   }
@@ -613,21 +556,12 @@ public class MTreeBelowSGMemoryImpl implements IMTreeBelowSG {
     String[] nodeNames = deviceId.getNodes();
     IMNode cur = storageGroupMNode;
     IMNode child;
-    Template upperTemplate = cur.getSchemaTemplate();
     for (int i = levelOfSG + 1; i < nodeNames.length; i++) {
       child = cur.getChild(nodeNames[i]);
       if (child == null) {
-        if (cur.isUseTemplate()
-            && upperTemplate != null
-            && upperTemplate.getDirectNode(nodeNames[i]) != null) {
-          throw new PathAlreadyExistException(
-              cur.getPartialPath().concatNode(nodeNames[i]).getFullPath());
-        }
         child = store.addChild(cur, nodeNames[i], new InternalMNode(cur, nodeNames[i]));
       }
       cur = child;
-      // update upper template
-      upperTemplate = cur.getSchemaTemplate() == null ? upperTemplate : cur.getSchemaTemplate();
     }
     return cur;
   }
@@ -657,36 +591,12 @@ public class MTreeBelowSGMemoryImpl implements IMTreeBelowSG {
     String[] nodeNames = path.getNodes();
     IMNode cur = storageGroupMNode;
     IMNode child;
-    Template upperTemplate = cur.getSchemaTemplate();
-    boolean isInTemplate = false;
     for (int i = levelOfSG + 1; i < nodeNames.length; i++) {
-      if (isInTemplate) {
-        child = cur.getChild(nodeNames[i]);
-        if (child == null) {
-          return false;
-        }
-        if (child.isMeasurement()) {
-          return i == nodeNames.length - 1;
-        }
-      } else {
-        upperTemplate = cur.getSchemaTemplate() == null ? upperTemplate : cur.getSchemaTemplate();
-        child = cur.getChild(nodeNames[i]);
-        if (child == null) {
-          if (upperTemplate == null
-              || !cur.isUseTemplate()
-              || upperTemplate.getDirectNode(nodeNames[i]) == null) {
-            return false;
-          }
-          child = upperTemplate.getDirectNode(nodeNames[i]);
-          isInTemplate = true;
-          if (child.isMeasurement()) {
-            return i == nodeNames.length - 1;
-          }
-        } else {
-          if (child.isMeasurement()) {
-            return i == nodeNames.length - 1;
-          }
-        }
+      child = cur.getChild(nodeNames[i]);
+      if (child == null) {
+        return false;
+      } else if (child.isMeasurement()) {
+        return i == nodeNames.length - 1;
       }
       cur = child;
     }
@@ -1139,39 +1049,15 @@ public class MTreeBelowSGMemoryImpl implements IMTreeBelowSG {
     String[] nodes = path.getNodes();
     IMNode cur = storageGroupMNode;
     IMNode next;
-    Template upperTemplate = cur.getSchemaTemplate();
-    boolean isInTemplate = false;
     for (int i = levelOfSG + 1; i < nodes.length; i++) {
-      if (isInTemplate) {
-        next = cur.getChild(nodes[i]);
-        if (next == null) {
+      next = cur.getChild(nodes[i]);
+      if (next == null) {
+        throw new PathNotExistException(path.getFullPath(), true);
+      } else if (next.isMeasurement()) {
+        if (i == nodes.length - 1) {
+          return next;
+        } else {
           throw new PathNotExistException(path.getFullPath(), true);
-        } else if (next.isMeasurement()) {
-          if (i == nodes.length - 1) {
-            return next;
-          } else {
-            throw new PathNotExistException(path.getFullPath(), true);
-          }
-        }
-      } else {
-        if (cur.getSchemaTemplate() != null) {
-          upperTemplate = cur.getSchemaTemplate();
-        }
-        next = cur.getChild(nodes[i]);
-        if (next == null) {
-          if (upperTemplate == null
-              || !cur.isUseTemplate()
-              || upperTemplate.getDirectNode(nodes[i]) == null) {
-            throw new PathNotExistException(path.getFullPath(), true);
-          }
-          next = upperTemplate.getDirectNode(nodes[i]);
-          isInTemplate = true;
-        } else if (next.isMeasurement()) {
-          if (i == nodes.length - 1) {
-            return next;
-          } else {
-            throw new PathNotExistException(path.getFullPath(), true);
-          }
         }
       }
       cur = next;
@@ -1232,412 +1118,6 @@ public class MTreeBelowSGMemoryImpl implements IMTreeBelowSG {
   // endregion
 
   // region Interfaces and Implementation for Template check and query
-  /**
-   * check whether there is template on given path and the subTree has template return true,
-   * otherwise false
-   */
-  @Override
-  public void checkTemplateOnPath(PartialPath path) throws MetadataException {
-    String[] nodeNames = path.getNodes();
-    IMNode cur = storageGroupMNode;
-    IMNode child;
-
-    if (cur.getSchemaTemplate() != null) {
-      throw new MetadataException("Template already exists on " + cur.getFullPath());
-    }
-
-    for (int i = levelOfSG + 1; i < nodeNames.length; i++) {
-      child = cur.getChild(nodeNames[i]);
-      if (child == null) {
-        return;
-      }
-      cur = child;
-      if (cur.getSchemaTemplate() != null) {
-        throw new MetadataException("Template already exists on " + cur.getFullPath());
-      }
-      if (cur.isMeasurement()) {
-        return;
-      }
-    }
-
-    checkTemplateOnSubtree(cur);
-  }
-
-  /**
-   * Check route 1: If template has no direct measurement, just pass the check.
-   *
-   * <p>Check route 2: If template has direct measurement and mounted node is Internal, it should be
-   * set to Entity.
-   *
-   * <p>Check route 3: If template has direct measurement and mounted node is Entity,
-   *
-   * <ul>
-   *   <p>route 3.1: mounted node has no measurement child, then its alignment will be set as the
-   *   template.
-   *   <p>route 3.2: mounted node has measurement child, then alignment of it and template should be
-   *   identical, otherwise cast a exception.
-   * </ul>
-   *
-   * @return return the node competent to be mounted.
-   */
-  @Override
-  public IMNode checkTemplateAlignmentWithMountedNode(IMNode mountedNode, Template template)
-      throws MetadataException {
-    boolean hasDirectMeasurement = false;
-    for (IMNode child : template.getDirectNodes()) {
-      if (child.isMeasurement()) {
-        hasDirectMeasurement = true;
-      }
-    }
-    if (!hasDirectMeasurement) {
-      return mountedNode;
-    }
-    if (!mountedNode.isEntity()) {
-      return setToEntity(mountedNode);
-    } else {
-      IMNode child;
-      IMNodeIterator iterator = store.getChildrenIterator(mountedNode);
-      while (iterator.hasNext()) {
-        child = iterator.next();
-        if (child.isMeasurement()) {
-          if (template.isDirectAligned() != mountedNode.getAsEntityMNode().isAligned()) {
-            throw new MetadataException(
-                "Template and mounted node has different alignment: "
-                    + template.getName()
-                    + mountedNode.getFullPath());
-          } else {
-            return mountedNode;
-          }
-        }
-      }
-
-      mountedNode.getAsEntityMNode().setAligned(template.isDirectAligned());
-    }
-    return mountedNode;
-  }
-
-  // traverse  all the  descendant of the given path node
-  private void checkTemplateOnSubtree(IMNode node) throws MetadataException {
-    if (node.isMeasurement()) {
-      return;
-    }
-    IMNode child;
-    IMNodeIterator iterator = store.getChildrenIterator(node);
-    while (iterator.hasNext()) {
-      child = iterator.next();
-
-      if (child.isMeasurement()) {
-        continue;
-      }
-      if (child.getSchemaTemplate() != null) {
-        throw new MetadataException("Template already exists on " + child.getFullPath());
-      }
-      checkTemplateOnSubtree(child);
-    }
-  }
-
-  @Override
-  public void checkIsTemplateCompatibleWithChild(IMNode node, Template template)
-      throws MetadataException {
-    for (String measurementPath : template.getSchemaMap().keySet()) {
-      String directNodeName = PathUtils.splitPathToDetachedNodes(measurementPath)[0];
-      if (node.hasChild(directNodeName)) {
-        throw new MetadataException(
-            "Node name "
-                + directNodeName
-                + " in template has conflict with node's child "
-                + (node.getFullPath() + "." + directNodeName));
-      }
-    }
-  }
-
-  @Override
-  public void checkTemplateInUseOnLowerNode(IMNode node) throws MetadataException {
-    if (node.isMeasurement()) {
-      return;
-    }
-    IMNode child;
-    IMNodeIterator iterator = store.getChildrenIterator(node);
-    while (iterator.hasNext()) {
-      child = iterator.next();
-
-      if (child.isMeasurement()) {
-        continue;
-      }
-      if (child.isUseTemplate()) {
-        throw new TemplateIsInUseException(child.getFullPath());
-      }
-      checkTemplateInUseOnLowerNode(child);
-    }
-  }
-
-  /**
-   * Check that each node set with tarTemplate and its descendants have overlapping nodes with
-   * appending measurements
-   */
-  @Override
-  public boolean isTemplateAppendable(Template tarTemplate, List<String> appendMeasurements)
-      throws MetadataException {
-    List<String> setPaths = getPathsSetOnTemplate(tarTemplate.getName());
-    if (setPaths.size() == 0) {
-      return true;
-    }
-    Deque<IMNode> setNodes = new ArrayDeque<>();
-
-    for (String path : setPaths) {
-      setNodes.add(getNodeByPath(new PartialPath(path)));
-    }
-    // since overlap of template and MTree is not allowed, it is sufficient to check on the first
-    // node
-    Set<String> overlapSet = new HashSet<>();
-    for (String path : appendMeasurements) {
-      overlapSet.add(PathUtils.splitPathToDetachedNodes(path)[0]);
-    }
-
-    while (setNodes.size() != 0) {
-      IMNode cur = setNodes.pop();
-
-      IMNodeIterator iterator = store.getChildrenIterator(cur);
-      IMNode child;
-      while (iterator.hasNext()) {
-        child = iterator.next();
-        if (overlapSet.contains(child.getName())) {
-          return false;
-        }
-        if (!child.isMeasurement()) {
-          setNodes.push(child);
-        }
-      }
-    }
-    return true;
-  }
-
-  /**
-   * Note that template and MTree cannot have overlap paths.
-   *
-   * @return true iff path corresponding to a measurement inside a template, whether using or not.
-   */
-  @Override
-  public boolean isPathExistsWithinTemplate(PartialPath path) throws MetadataException {
-    String[] pathNodes = path.getNodes();
-    IMNode cur = storageGroupMNode;
-    IMNode child;
-    Template upperTemplate = cur.getUpperTemplate();
-
-    for (int i = levelOfSG + 1; i < pathNodes.length; i++) {
-      child = cur.getChild(pathNodes[i]);
-      if (child != null) {
-        cur = child;
-        if (cur.isMeasurement()) {
-          return false;
-        }
-        upperTemplate = cur.getSchemaTemplate() == null ? upperTemplate : cur.getSchemaTemplate();
-      } else {
-        if (upperTemplate != null) {
-          String suffixPath =
-              new PartialPath(Arrays.copyOfRange(pathNodes, i, pathNodes.length)).toString();
-          // has template, whether match
-          return upperTemplate.hasSchema(suffixPath);
-        } else {
-          // no child and no template
-          return false;
-        }
-      }
-    }
-    return false;
-  }
-
-  /**
-   * Check measurement path and return the mounted node index on path. The node could have not
-   * created yet. The result is used for getDeviceNodeWithAutoCreate, which return corresponding
-   * IMNode on MTree.
-   *
-   * @return index on full path of the node which matches all measurements' path with its
-   *     upperTemplate.
-   */
-  @Override
-  public int getMountedNodeIndexOnMeasurementPath(PartialPath devicePath, String[] measurements)
-      throws MetadataException {
-    String[] nodes = devicePath.getNodes();
-    IMNode cur = storageGroupMNode;
-    IMNode child;
-    Template upperTemplate = cur.getSchemaTemplate();
-    int index;
-    boolean attemptToUseTemplate = false;
-
-    // If there are nodes of target path on MTree, use it as possible.
-    for (index = levelOfSG + 1; index < nodes.length; index++) {
-      upperTemplate = cur.getSchemaTemplate() != null ? cur.getSchemaTemplate() : upperTemplate;
-      child = cur.getChild(nodes[index]);
-      if (child == null) {
-        if (upperTemplate == null) {
-          // no matched child, no template, need to create device node as logical device path
-          return nodes.length;
-        } else {
-          attemptToUseTemplate = true;
-          break;
-        }
-      } else {
-        // has child on MTree
-        cur = child;
-      }
-    }
-
-    if (!attemptToUseTemplate) {
-      // all nodes on path exist in MTree, device node should be the penultimate one
-      return nodes.length;
-    }
-
-    // The resting part of target path not exists on MTree, thus try to use template.
-    for (; index < nodes.length; index++) {
-      int fullPathLength = nodes.length - index + 1;
-      String[] suffixNodes = new String[fullPathLength];
-      System.arraycopy(nodes, index, suffixNodes, 0, nodes.length - index);
-      boolean hasAllMeasurements = true;
-
-      for (String measurement : measurements) {
-        // for this fullPath, cur is the last node on MTree
-        // since upperTemplate exists, need to find the matched suffix path of fullPath and
-        // template
-        suffixNodes[fullPathLength - 1] = measurement;
-        String suffixPath = String.join(String.valueOf(PATH_SEPARATOR), suffixNodes);
-
-        if (upperTemplate.hasSchema(suffixPath)) {
-          continue;
-        }
-
-        // if suffix doesn't match, but first node name matched, it's an overlap with template
-        // cast exception for now
-        if (upperTemplate.getDirectNode(nodes[index]) != null) {
-          throw new TemplateImcompatibeException(
-              devicePath.concatNode(measurement).getFullPath(),
-              upperTemplate.getName(),
-              nodes[index]);
-        }
-
-        hasAllMeasurements = false;
-      }
-
-      if (hasAllMeasurements) {
-        return index - 1;
-      }
-    }
-
-    return nodes.length;
-  }
-
-  @Override
-  public List<String> getPathsSetOnTemplate(String templateName) throws MetadataException {
-    List<String> resSet = new ArrayList<>();
-    CollectorTraverser<Set<String>> setTemplatePaths =
-        new CollectorTraverser<Set<String>>(
-            storageGroupMNode, new PartialPath(ALL_RESULT_NODES), store) {
-          @Override
-          protected boolean processInternalMatchedMNode(IMNode node, int idx, int level) {
-            // will never get here, implement for placeholder
-            return false;
-          }
-
-          @Override
-          protected boolean processFullMatchedMNode(IMNode node, int idx, int level)
-              throws MetadataException {
-            // shall not traverse nodes inside template or measurement ones
-            if (!node.getPartialPath().equals(getCurrentPartialPath(node))
-                || node.isMeasurement()) {
-              return true;
-            }
-
-            // if node not set template, go on traversing
-            if (node.getSchemaTemplate() != null) {
-              // if set template, and equals to target or target for all, add to result
-              if (templateName.equals(ONE_LEVEL_PATH_WILDCARD)
-                  || templateName.equals(node.getUpperTemplate().getName())) {
-                resSet.add(node.getFullPath());
-              }
-              // descendants of the node cannot set another template, exit from this branch
-              return true;
-            }
-            return false;
-          }
-        };
-    setTemplatePaths.traverse();
-    return resSet;
-  }
-
-  @Override
-  public List<String> getPathsUsingTemplate(String templateName) throws MetadataException {
-    List<String> result = new ArrayList<>();
-
-    CollectorTraverser<Set<String>> usingTemplatePaths =
-        new CollectorTraverser<Set<String>>(
-            storageGroupMNode, new PartialPath(ALL_RESULT_NODES), store) {
-          @Override
-          protected boolean processInternalMatchedMNode(IMNode node, int idx, int level) {
-            // will never get here, implement for placeholder
-            return false;
-          }
-
-          @Override
-          protected boolean processFullMatchedMNode(IMNode node, int idx, int level) {
-            // shall not traverse nodes inside template or measurement ones
-            if (!node.getPartialPath().equals(getCurrentPartialPath(node))
-                || node.isMeasurement()) {
-              return true;
-            }
-
-            if (node.getUpperTemplate() != null) {
-              // this node and its descendants are set other template, exit from this branch
-              if (!templateName.equals(ONE_LEVEL_PATH_WILDCARD)
-                  && !templateName.equals(node.getUpperTemplate().getName())) {
-                return true;
-              }
-
-              // descendants of this node may be using template too
-              if (node.isUseTemplate()) {
-                result.add(node.getFullPath());
-              }
-            }
-            return false;
-          }
-        };
-
-    usingTemplatePaths.traverse();
-    return result;
-  }
-
-  /**
-   * Get template name on give path if any node of it has been set a template
-   *
-   * @return null if no template has been set on path
-   */
-  @Override
-  public String getTemplateOnPath(PartialPath path) throws MetadataException {
-    String[] pathNodes = path.getNodes();
-    IMNode cur = storageGroupMNode;
-    IMNode child;
-
-    if (cur.getSchemaTemplate() != null) {
-      return cur.getSchemaTemplate().getName();
-    }
-
-    for (int i = levelOfSG + 1; i < pathNodes.length; i++) {
-      child = cur.getChild(pathNodes[i]);
-      if (child == null) {
-        return null;
-      }
-      cur = child;
-
-      if (cur.isMeasurement()) {
-        return null;
-      }
-
-      if (cur.getSchemaTemplate() != null) {
-        return cur.getSchemaTemplate().getName();
-      }
-    }
-
-    return null;
-  }
 
   @Override
   public void activateTemplate(PartialPath activatePath, Template template)
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/store/disk/schemafile/MockSchemaFile.java b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/store/disk/schemafile/MockSchemaFile.java
index 1dd21f4ab7..f0092a37c7 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/store/disk/schemafile/MockSchemaFile.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/store/disk/schemafile/MockSchemaFile.java
@@ -214,7 +214,6 @@ public class MockSchemaFile implements ISchemaFile {
 
   private static void cloneInternalMNodeData(IMNode node, IMNode result) {
     result.setUseTemplate(node.isUseTemplate());
-    result.setSchemaTemplate(node.getSchemaTemplate());
     ICachedMNodeContainer container = new CachedMNodeContainer();
     container.setSegmentAddress((getCachedMNodeContainer(node)).getSegmentAddress());
     result.setChildren(container);
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/store/disk/schemafile/RecordUtils.java b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/store/disk/schemafile/RecordUtils.java
index 6570ce1e33..b4118142dd 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/store/disk/schemafile/RecordUtils.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/store/disk/schemafile/RecordUtils.java
@@ -20,14 +20,12 @@ package org.apache.iotdb.db.metadata.mtree.store.disk.schemafile;
 
 import org.apache.iotdb.commons.exception.MetadataException;
 import org.apache.iotdb.commons.utils.TestOnly;
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.metadata.mnode.EntityMNode;
 import org.apache.iotdb.db.metadata.mnode.IMNode;
 import org.apache.iotdb.db.metadata.mnode.IMeasurementMNode;
 import org.apache.iotdb.db.metadata.mnode.InternalMNode;
 import org.apache.iotdb.db.metadata.mnode.MeasurementMNode;
 import org.apache.iotdb.db.metadata.mtree.store.disk.ICachedMNodeContainer;
-import org.apache.iotdb.db.metadata.template.ClusterTemplateManager;
 import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
@@ -189,7 +187,7 @@ public class RecordUtils {
       resNode.setUseTemplate(usingTemplate);
       resNode.setSchemaTemplateId(templateId);
 
-      return paddingTemplate(resNode, templateId);
+      return resNode;
     } else {
       // measurement node
       short recLenth = ReadWriteIOUtils.readShort(buffer);
@@ -321,16 +319,6 @@ public class RecordUtils {
     return node.getOffset();
   }
 
-  private static IMNode paddingTemplate(IMNode node, int templateId) {
-    // TODO: Remove this conditional judgment after removing the standalone version
-    if (IoTDBDescriptor.getInstance().getConfig().isClusterMode()) {
-      if (templateId > 0) {
-        node.setSchemaTemplate(ClusterTemplateManager.getInstance().getTemplate(templateId));
-      }
-    }
-    return node;
-  }
-
   /** Including schema and pre-delete flag of a measurement, could be expanded further. */
   private static long convertMeasStat2Long(IMeasurementMNode node) {
     byte dataType = node.getSchema().getTypeInByte();
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/store/disk/schemafile/SchemaFile.java b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/store/disk/schemafile/SchemaFile.java
index b6ef06afd6..837f7f1341 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/store/disk/schemafile/SchemaFile.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/store/disk/schemafile/SchemaFile.java
@@ -33,7 +33,6 @@ import org.apache.iotdb.db.metadata.mtree.store.disk.ICachedMNodeContainer;
 import org.apache.iotdb.db.metadata.mtree.store.disk.schemafile.pagemgr.BTreePageManager;
 import org.apache.iotdb.db.metadata.mtree.store.disk.schemafile.pagemgr.IPageManager;
 import org.apache.iotdb.db.metadata.mtree.store.disk.schemafile.pagemgr.PageManager;
-import org.apache.iotdb.db.metadata.template.TemplateManager;
 import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
 
 import org.slf4j.Logger;
@@ -178,7 +177,9 @@ public class SchemaFile implements ISchemaFile {
     }
     resNode.setFullPath(storageGroupName);
     if (templateHash != 0) {
-      resNode.setSchemaTemplate(TemplateManager.getInstance().getTemplateFromHash(templateHash));
+      //
+      // resNode.setSchemaTemplate(TemplateManager.getInstance().getTemplateFromHash(templateHash));
+      // todo record the templateId generated in configNode
     }
     return resNode;
   }
@@ -187,8 +188,9 @@ public class SchemaFile implements ISchemaFile {
   public boolean updateStorageGroupNode(IStorageGroupMNode sgNode) throws IOException {
     this.dataTTL = sgNode.getDataTTL();
     this.isEntity = sgNode.isEntity();
-    this.templateHash =
-        sgNode.getSchemaTemplate() == null ? 0 : sgNode.getSchemaTemplate().hashCode();
+    // todo record the templateId generated in configNode
+    //    this.templateHash =
+    //        sgNode.getSchemaTemplate() == null ? 0 : sgNode.getSchemaTemplate().hashCode();
     updateHeader();
     return true;
   }
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/traverser/Traverser.java b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/traverser/Traverser.java
index 119d6b2d83..47a16bcb21 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/traverser/Traverser.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/traverser/Traverser.java
@@ -252,15 +252,15 @@ public abstract class Traverser {
       return;
     }
 
-    Template upperTemplate = getUpperTemplate(node);
-    if (upperTemplate == null) {
+    Template schemaTemplate = getActivatedSchemaTemplate(node);
+    if (schemaTemplate == null) {
       // template == null means the template used by this node is not related to this query in new
       // cluster.
       return;
     }
     isInTemplate = true;
     traverseContext.push(node);
-    for (IMNode childInTemplate : upperTemplate.getDirectNodes()) {
+    for (IMNode childInTemplate : schemaTemplate.getDirectNodes()) {
       traverse(childInTemplate, idx + 1, level + 1);
     }
     traverseContext.pop();
@@ -346,15 +346,15 @@ public abstract class Traverser {
       return;
     }
 
-    Template upperTemplate = getUpperTemplate(node);
-    if (upperTemplate == null) {
+    Template schemaTemplate = getActivatedSchemaTemplate(node);
+    if (schemaTemplate == null) {
       // template == null means the template used by this node is not related to this query in new
       // cluster.
       return;
     }
     isInTemplate = true;
     traverseContext.push(node);
-    for (IMNode childInTemplate : upperTemplate.getDirectNodes()) {
+    for (IMNode childInTemplate : schemaTemplate.getDirectNodes()) {
       if (!Pattern.matches(targetNameRegex, childInTemplate.getName())) {
         continue;
       }
@@ -364,7 +364,7 @@ public abstract class Traverser {
 
     if (multiLevelWildcard) {
       traverseContext.push(node);
-      for (IMNode childInTemplate : upperTemplate.getDirectNodes()) {
+      for (IMNode childInTemplate : schemaTemplate.getDirectNodes()) {
         traverse(childInTemplate, idx, level + 1);
       }
       traverseContext.pop();
@@ -433,14 +433,14 @@ public abstract class Traverser {
       return;
     }
 
-    Template upperTemplate = getUpperTemplate(node);
-    if (upperTemplate == null) {
+    Template schemaTemplate = getActivatedSchemaTemplate(node);
+    if (schemaTemplate == null) {
       // template == null means the template used by this node is not related to this query in new
       // cluster.
       return;
     }
     isInTemplate = true;
-    IMNode targetNode = upperTemplate.getDirectNode(targetName);
+    IMNode targetNode = schemaTemplate.getDirectNode(targetName);
     if (targetNode != null) {
       traverseContext.push(node);
       traverse(targetNode, idx + 1, level + 1);
@@ -449,7 +449,7 @@ public abstract class Traverser {
 
     if (multiLevelWildcard) {
       traverseContext.push(node);
-      for (IMNode child : upperTemplate.getDirectNodes()) {
+      for (IMNode child : schemaTemplate.getDirectNodes()) {
         traverse(child, idx, level + 1);
       }
       traverseContext.pop();
@@ -457,29 +457,14 @@ public abstract class Traverser {
     isInTemplate = false;
   }
 
-  protected Template getUpperTemplate(IMNode node) {
-    Iterator<IMNode> iterator = traverseContext.iterator();
-    IMNode ancestor;
-    if (templateMap == null) {
-      // old standalone
-      if (node.getSchemaTemplate() != null) {
-        return node.getUpperTemplate();
-      }
-      while (iterator.hasNext()) {
-        ancestor = iterator.next();
-        if (ancestor.getSchemaTemplate() != null) {
-          return ancestor.getSchemaTemplate();
-        }
-      }
-    } else {
-      // new cluster, the used template is directly recorded as template id in device mnode
-      if (node.getSchemaTemplateId() != NON_TEMPLATE) {
-        if (skipPreDeletedSchema && node.getAsEntityMNode().isPreDeactivateTemplate()) {
-          // skip this pre deactivated template, the invoker will skip this
-          return null;
-        }
-        return templateMap.get(node.getSchemaTemplateId());
+  protected Template getActivatedSchemaTemplate(IMNode node) {
+    // new cluster, the used template is directly recorded as template id in device mnode
+    if (node.getSchemaTemplateId() != NON_TEMPLATE) {
+      if (skipPreDeletedSchema && node.getAsEntityMNode().isPreDeactivateTemplate()) {
+        // skip this pre deactivated template, the invoker will skip this
+        return null;
       }
+      return templateMap.get(node.getSchemaTemplateId());
     }
     // if the node is usingTemplate, the upperTemplate won't be null or the upperTemplateId won't be
     // NON_TEMPLATE.
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/SchemaRegionPlanType.java b/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/SchemaRegionPlanType.java
index fadf837323..94e9af187e 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/SchemaRegionPlanType.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/SchemaRegionPlanType.java
@@ -31,11 +31,11 @@ public enum SchemaRegionPlanType {
   DELETE_TIMESERIES((byte) 21),
   CHANGE_TAG_OFFSET((byte) 28),
   CHANGE_ALIAS((byte) 29),
-  SET_TEMPLATE((byte) 38),
-  ACTIVATE_TEMPLATE((byte) 39),
+  //  SET_TEMPLATE((byte) 38),
+  //  ACTIVATE_TEMPLATE((byte) 39),
   AUTO_CREATE_DEVICE_MNODE((byte) 40),
   CREATE_ALIGNED_TIMESERIES((byte) 41),
-  UNSET_TEMPLATE((byte) 57),
+  //  UNSET_TEMPLATE((byte) 57),
   ACTIVATE_TEMPLATE_IN_CLUSTER((byte) 63),
   PRE_DELETE_TIMESERIES_IN_CLUSTER((byte) 64),
   ROLLBACK_PRE_DELETE_TIMESERIES((byte) 65),
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/SchemaRegionPlanVisitor.java b/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/SchemaRegionPlanVisitor.java
index 40fae83f6d..355480f96c 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/SchemaRegionPlanVisitor.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/SchemaRegionPlanVisitor.java
@@ -20,7 +20,6 @@
 package org.apache.iotdb.db.metadata.plan.schemaregion;
 
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IActivateTemplateInClusterPlan;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.IActivateTemplatePlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IAutoCreateDeviceMNodePlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IChangeAliasPlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IChangeTagOffsetPlan;
@@ -32,8 +31,6 @@ import org.apache.iotdb.db.metadata.plan.schemaregion.write.IPreDeactivateTempla
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IPreDeleteTimeSeriesPlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IRollbackPreDeactivateTemplatePlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IRollbackPreDeleteTimeSeriesPlan;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.ISetTemplatePlan;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.IUnsetTemplatePlan;
 
 public abstract class SchemaRegionPlanVisitor<R, C> {
 
@@ -44,10 +41,6 @@ public abstract class SchemaRegionPlanVisitor<R, C> {
     return visitSchemaRegionPlan(activateTemplateInClusterPlan, context);
   }
 
-  public R visitActivateTemplate(IActivateTemplatePlan activateTemplatePlan, C context) {
-    return visitSchemaRegionPlan(activateTemplatePlan, context);
-  }
-
   public R visitAutoCreateDeviceMNode(
       IAutoCreateDeviceMNodePlan autoCreateDeviceMNodePlan, C context) {
     return visitSchemaRegionPlan(autoCreateDeviceMNodePlan, context);
@@ -83,14 +76,6 @@ public abstract class SchemaRegionPlanVisitor<R, C> {
     return visitSchemaRegionPlan(rollbackPreDeleteTimeSeriesPlan, context);
   }
 
-  public R visitSetTemplate(ISetTemplatePlan setTemplatePlan, C context) {
-    return visitSchemaRegionPlan(setTemplatePlan, context);
-  }
-
-  public R visitUnsetTemplate(IUnsetTemplatePlan unsetTemplatePlan, C context) {
-    return visitSchemaRegionPlan(unsetTemplatePlan, context);
-  }
-
   public R visitPreDeactivateTemplate(
       IPreDeactivateTemplatePlan preDeactivateTemplatePlan, C context) {
     return visitSchemaRegionPlan(preDeactivateTemplatePlan, context);
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/impl/ActivateTemplatePlanImpl.java b/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/impl/ActivateTemplatePlanImpl.java
deleted file mode 100644
index 885e52d4bc..0000000000
--- a/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/impl/ActivateTemplatePlanImpl.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.metadata.plan.schemaregion.impl;
-
-import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.IActivateTemplatePlan;
-
-public class ActivateTemplatePlanImpl implements IActivateTemplatePlan {
-
-  PartialPath prefixPath;
-
-  public ActivateTemplatePlanImpl() {}
-
-  public ActivateTemplatePlanImpl(PartialPath prefixPath) {
-    this.prefixPath = prefixPath;
-  }
-
-  @Override
-  public PartialPath getPrefixPath() {
-    return prefixPath;
-  }
-
-  @Override
-  public void setPrefixPath(PartialPath prefixPath) {
-    this.prefixPath = prefixPath;
-  }
-}
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/impl/SchemaRegionPlanDeserializer.java b/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/impl/SchemaRegionPlanDeserializer.java
index 6588ebf2f9..f25f59d2de 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/impl/SchemaRegionPlanDeserializer.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/impl/SchemaRegionPlanDeserializer.java
@@ -27,7 +27,6 @@ import org.apache.iotdb.db.metadata.plan.schemaregion.ISchemaRegionPlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.SchemaRegionPlanType;
 import org.apache.iotdb.db.metadata.plan.schemaregion.SchemaRegionPlanVisitor;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IActivateTemplateInClusterPlan;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.IActivateTemplatePlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IAutoCreateDeviceMNodePlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IChangeAliasPlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IChangeTagOffsetPlan;
@@ -39,8 +38,6 @@ import org.apache.iotdb.db.metadata.plan.schemaregion.write.IPreDeactivateTempla
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IPreDeleteTimeSeriesPlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IRollbackPreDeactivateTemplatePlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IRollbackPreDeleteTimeSeriesPlan;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.ISetTemplatePlan;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.IUnsetTemplatePlan;
 import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
@@ -98,20 +95,6 @@ public class SchemaRegionPlanDeserializer implements IDeserializer<ISchemaRegion
       return activateTemplateInClusterPlan;
     }
 
-    @Override
-    public ISchemaRegionPlan visitActivateTemplate(
-        IActivateTemplatePlan activateTemplatePlan, ByteBuffer buffer) {
-      try {
-        activateTemplatePlan.setPrefixPath(new PartialPath(ReadWriteIOUtils.readString(buffer)));
-      } catch (IllegalPathException e) {
-        LOGGER.error("Cannot deserialize SchemaRegionPlan from buffer", e);
-      }
-
-      // deserialize a long to keep compatible with old version (raft index)
-      buffer.getLong();
-      return activateTemplatePlan;
-    }
-
     @Override
     public ISchemaRegionPlan visitAutoCreateDeviceMNode(
         IAutoCreateDeviceMNodePlan autoCreateDeviceMNodePlan, ByteBuffer buffer) {
@@ -315,29 +298,6 @@ public class SchemaRegionPlanDeserializer implements IDeserializer<ISchemaRegion
       return rollbackPreDeleteTimeSeriesPlan;
     }
 
-    @Override
-    public ISchemaRegionPlan visitSetTemplate(ISetTemplatePlan setTemplatePlan, ByteBuffer buffer) {
-      setTemplatePlan.setTemplateName(ReadWriteIOUtils.readString(buffer));
-      setTemplatePlan.setPrefixPath(ReadWriteIOUtils.readString(buffer));
-
-      // deserialize a long to keep compatible with old version (raft index)
-      buffer.getLong();
-
-      return setTemplatePlan;
-    }
-
-    @Override
-    public ISchemaRegionPlan visitUnsetTemplate(
-        IUnsetTemplatePlan unsetTemplatePlan, ByteBuffer buffer) {
-      unsetTemplatePlan.setPrefixPath(ReadWriteIOUtils.readString(buffer));
-      unsetTemplatePlan.setTemplateName(ReadWriteIOUtils.readString(buffer));
-
-      // deserialize a long to keep compatible with old version (raft index)
-      buffer.getLong();
-
-      return unsetTemplatePlan;
-    }
-
     @Override
     public ISchemaRegionPlan visitPreDeactivateTemplate(
         IPreDeactivateTemplatePlan preDeactivateTemplatePlan, ByteBuffer buffer) {
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/impl/SchemaRegionPlanFactory.java b/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/impl/SchemaRegionPlanFactory.java
index 0f5c38d7ea..53bad3c928 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/impl/SchemaRegionPlanFactory.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/impl/SchemaRegionPlanFactory.java
@@ -22,7 +22,6 @@ package org.apache.iotdb.db.metadata.plan.schemaregion.impl;
 import org.apache.iotdb.commons.path.PartialPath;
 import org.apache.iotdb.db.metadata.plan.schemaregion.ISchemaRegionPlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.SchemaRegionPlanType;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.IActivateTemplatePlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IAutoCreateDeviceMNodePlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IChangeAliasPlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IChangeTagOffsetPlan;
@@ -55,16 +54,10 @@ public class SchemaRegionPlanFactory {
         return new ChangeTagOffsetPlanImpl();
       case CHANGE_ALIAS:
         return new ChangeAliasPlanImpl();
-      case SET_TEMPLATE:
-        return new SetTemplatePlanImpl();
-      case ACTIVATE_TEMPLATE:
-        return new ActivateTemplatePlanImpl();
       case AUTO_CREATE_DEVICE_MNODE:
         return new AutoCreateDeviceMNodePlanImpl();
       case CREATE_ALIGNED_TIMESERIES:
         return new CreateAlignedTimeSeriesPlanImpl();
-      case UNSET_TEMPLATE:
-        return new UnsetTemplatePlanImpl();
       case ACTIVATE_TEMPLATE_IN_CLUSTER:
         return new ActivateTemplateInClusterPlanImpl();
       case PRE_DELETE_TIMESERIES_IN_CLUSTER:
@@ -93,10 +86,6 @@ public class SchemaRegionPlanFactory {
     return new ChangeTagOffsetPlanImpl(fullPath, tagOffset);
   }
 
-  public static IActivateTemplatePlan getActivateTemplatePlan(PartialPath path) {
-    return new ActivateTemplatePlanImpl(path);
-  }
-
   public static IAutoCreateDeviceMNodePlan getAutoCreateDeviceMNodePlan(PartialPath path) {
     return new AutoCreateDeviceMNodePlanImpl(path);
   }
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/impl/SchemaRegionPlanSerializer.java b/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/impl/SchemaRegionPlanSerializer.java
index 4f4b4167a4..d421211663 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/impl/SchemaRegionPlanSerializer.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/impl/SchemaRegionPlanSerializer.java
@@ -24,7 +24,6 @@ import org.apache.iotdb.db.metadata.logfile.ISerializer;
 import org.apache.iotdb.db.metadata.plan.schemaregion.ISchemaRegionPlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.SchemaRegionPlanVisitor;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IActivateTemplateInClusterPlan;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.IActivateTemplatePlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IAutoCreateDeviceMNodePlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IChangeAliasPlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IChangeTagOffsetPlan;
@@ -36,8 +35,6 @@ import org.apache.iotdb.db.metadata.plan.schemaregion.write.IPreDeactivateTempla
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IPreDeleteTimeSeriesPlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IRollbackPreDeactivateTemplatePlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IRollbackPreDeleteTimeSeriesPlan;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.ISetTemplatePlan;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.IUnsetTemplatePlan;
 import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
@@ -133,20 +130,6 @@ public class SchemaRegionPlanSerializer implements ISerializer<ISchemaRegionPlan
       }
     }
 
-    @Override
-    public SchemaRegionPlanSerializationResult visitActivateTemplate(
-        IActivateTemplatePlan activateTemplatePlan, DataOutputStream dataOutputStream) {
-      try {
-        ReadWriteIOUtils.write(
-            activateTemplatePlan.getPrefixPath().getFullPath(), dataOutputStream);
-        // serialize a long to keep compatible with old version (raft index)
-        dataOutputStream.writeLong(0);
-        return SchemaRegionPlanSerializationResult.SUCCESS;
-      } catch (IOException e) {
-        return new SchemaRegionPlanSerializationResult(e);
-      }
-    }
-
     @Override
     public SchemaRegionPlanSerializationResult visitAutoCreateDeviceMNode(
         IAutoCreateDeviceMNodePlan autoCreateDeviceMNodePlan, DataOutputStream dataOutputStream) {
@@ -367,38 +350,6 @@ public class SchemaRegionPlanSerializer implements ISerializer<ISchemaRegionPlan
       }
     }
 
-    @Override
-    public SchemaRegionPlanSerializationResult visitSetTemplate(
-        ISetTemplatePlan setTemplatePlan, DataOutputStream dataOutputStream) {
-      try {
-        ReadWriteIOUtils.write(setTemplatePlan.getTemplateName(), dataOutputStream);
-        ReadWriteIOUtils.write(setTemplatePlan.getPrefixPath(), dataOutputStream);
-
-        // serialize a long to keep compatible with old version (raft index)
-        dataOutputStream.writeLong(0);
-
-        return SchemaRegionPlanSerializationResult.SUCCESS;
-      } catch (IOException e) {
-        return new SchemaRegionPlanSerializationResult(e);
-      }
-    }
-
-    @Override
-    public SchemaRegionPlanSerializationResult visitUnsetTemplate(
-        IUnsetTemplatePlan unsetTemplatePlan, DataOutputStream dataOutputStream) {
-      try {
-        ReadWriteIOUtils.write(unsetTemplatePlan.getPrefixPath(), dataOutputStream);
-        ReadWriteIOUtils.write(unsetTemplatePlan.getTemplateName(), dataOutputStream);
-
-        // serialize a long to keep compatible with old version (raft index)
-        dataOutputStream.writeLong(0);
-
-        return SchemaRegionPlanSerializationResult.SUCCESS;
-      } catch (IOException e) {
-        return new SchemaRegionPlanSerializationResult(e);
-      }
-    }
-
     @Override
     public SchemaRegionPlanSerializationResult visitPreDeactivateTemplate(
         IPreDeactivateTemplatePlan preDeactivateTemplatePlan, DataOutputStream dataOutputStream) {
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/impl/SchemaRegionPlanTxtSerializer.java b/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/impl/SchemaRegionPlanTxtSerializer.java
index 7d8cfad2a0..c820f0db95 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/impl/SchemaRegionPlanTxtSerializer.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/impl/SchemaRegionPlanTxtSerializer.java
@@ -24,7 +24,6 @@ import org.apache.iotdb.db.metadata.logfile.ISerializer;
 import org.apache.iotdb.db.metadata.plan.schemaregion.ISchemaRegionPlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.SchemaRegionPlanVisitor;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IActivateTemplateInClusterPlan;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.IActivateTemplatePlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IAutoCreateDeviceMNodePlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IChangeAliasPlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IChangeTagOffsetPlan;
@@ -36,8 +35,6 @@ import org.apache.iotdb.db.metadata.plan.schemaregion.write.IPreDeactivateTempla
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IPreDeleteTimeSeriesPlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IRollbackPreDeactivateTemplatePlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IRollbackPreDeleteTimeSeriesPlan;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.ISetTemplatePlan;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.IUnsetTemplatePlan;
 import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
@@ -90,13 +87,6 @@ public class SchemaRegionPlanTxtSerializer implements ISerializer<ISchemaRegionP
       return null;
     }
 
-    @Override
-    public Void visitActivateTemplate(
-        IActivateTemplatePlan activateTemplatePlan, StringBuilder stringBuilder) {
-      stringBuilder.append(activateTemplatePlan.getPrefixPath().getFullPath());
-      return null;
-    }
-
     @Override
     public Void visitAutoCreateDeviceMNode(
         IAutoCreateDeviceMNodePlan autoCreateDeviceMNodePlan, StringBuilder stringBuilder) {
@@ -222,25 +212,6 @@ public class SchemaRegionPlanTxtSerializer implements ISerializer<ISchemaRegionP
       return null;
     }
 
-    @Override
-    public Void visitSetTemplate(ISetTemplatePlan setTemplatePlan, StringBuilder stringBuilder) {
-      stringBuilder
-          .append(setTemplatePlan.getPrefixPath())
-          .append(FIELD_SEPARATOR)
-          .append(setTemplatePlan.getTemplateName());
-      return null;
-    }
-
-    @Override
-    public Void visitUnsetTemplate(
-        IUnsetTemplatePlan unsetTemplatePlan, StringBuilder stringBuilder) {
-      stringBuilder
-          .append(unsetTemplatePlan.getPrefixPath())
-          .append(FIELD_SEPARATOR)
-          .append(unsetTemplatePlan.getTemplateName());
-      return null;
-    }
-
     @Override
     public Void visitPreDeactivateTemplate(
         IPreDeactivateTemplatePlan preDeactivateTemplatePlan, StringBuilder stringBuilder) {
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/impl/SetTemplatePlanImpl.java b/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/impl/SetTemplatePlanImpl.java
deleted file mode 100644
index 3b5bf67124..0000000000
--- a/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/impl/SetTemplatePlanImpl.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.metadata.plan.schemaregion.impl;
-
-import org.apache.iotdb.commons.conf.IoTDBConstant;
-import org.apache.iotdb.commons.exception.IllegalPathException;
-import org.apache.iotdb.commons.utils.PathUtils;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.ISetTemplatePlan;
-
-public class SetTemplatePlanImpl implements ISetTemplatePlan {
-
-  private String templateName;
-
-  private String prefixPath;
-
-  public SetTemplatePlanImpl() {}
-
-  public SetTemplatePlanImpl(String templateName, String prefixPath) throws IllegalPathException {
-
-    String[] pathNodes = PathUtils.splitPathToDetachedNodes(prefixPath);
-    for (String s : pathNodes) {
-      if (s.equals(IoTDBConstant.ONE_LEVEL_PATH_WILDCARD)
-          || s.equals(IoTDBConstant.MULTI_LEVEL_PATH_WILDCARD)) {
-        throw new IllegalPathException(
-            prefixPath, "template cannot be set on a path with wildcard.");
-      }
-    }
-
-    this.templateName = templateName;
-    this.prefixPath = prefixPath;
-  }
-
-  @Override
-  public String getTemplateName() {
-    return templateName;
-  }
-
-  @Override
-  public void setTemplateName(String templateName) {
-    this.templateName = templateName;
-  }
-
-  @Override
-  public String getPrefixPath() {
-    return prefixPath;
-  }
-
-  @Override
-  public void setPrefixPath(String prefixPath) {
-    this.prefixPath = prefixPath;
-  }
-}
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/impl/UnsetTemplatePlanImpl.java b/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/impl/UnsetTemplatePlanImpl.java
deleted file mode 100644
index 7ea0633094..0000000000
--- a/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/impl/UnsetTemplatePlanImpl.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.iotdb.db.metadata.plan.schemaregion.impl;
-
-import org.apache.iotdb.commons.conf.IoTDBConstant;
-import org.apache.iotdb.commons.exception.IllegalPathException;
-import org.apache.iotdb.commons.utils.PathUtils;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.IUnsetTemplatePlan;
-
-public class UnsetTemplatePlanImpl implements IUnsetTemplatePlan {
-
-  private String prefixPath;
-  public String templateName;
-
-  public UnsetTemplatePlanImpl() {}
-
-  public UnsetTemplatePlanImpl(String prefixPath, String templateName) throws IllegalPathException {
-
-    String[] pathNodes = PathUtils.splitPathToDetachedNodes(prefixPath);
-    for (String s : pathNodes) {
-      if (s.equals(IoTDBConstant.ONE_LEVEL_PATH_WILDCARD)
-          || s.equals(IoTDBConstant.MULTI_LEVEL_PATH_WILDCARD)) {
-        throw new IllegalPathException(
-            prefixPath, "template cannot be unset on a path with wildcard.");
-      }
-    }
-
-    this.prefixPath = prefixPath;
-    this.templateName = templateName;
-  }
-
-  @Override
-  public String getPrefixPath() {
-    return prefixPath;
-  }
-
-  @Override
-  public void setPrefixPath(String prefixPath) {
-    this.prefixPath = prefixPath;
-  }
-
-  @Override
-  public String getTemplateName() {
-    return templateName;
-  }
-
-  @Override
-  public void setTemplateName(String templateName) {
-    this.templateName = templateName;
-  }
-}
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/write/IActivateTemplatePlan.java b/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/write/IActivateTemplatePlan.java
deleted file mode 100644
index e44ce02c6b..0000000000
--- a/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/write/IActivateTemplatePlan.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.metadata.plan.schemaregion.write;
-
-import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.db.metadata.plan.schemaregion.ISchemaRegionPlan;
-import org.apache.iotdb.db.metadata.plan.schemaregion.SchemaRegionPlanType;
-import org.apache.iotdb.db.metadata.plan.schemaregion.SchemaRegionPlanVisitor;
-
-public interface IActivateTemplatePlan extends ISchemaRegionPlan {
-
-  @Override
-  default SchemaRegionPlanType getPlanType() {
-    return SchemaRegionPlanType.ACTIVATE_TEMPLATE;
-  }
-
-  @Override
-  default <R, C> R accept(SchemaRegionPlanVisitor<R, C> visitor, C context) {
-    return visitor.visitActivateTemplate(this, context);
-  }
-
-  PartialPath getPrefixPath();
-
-  void setPrefixPath(PartialPath prefixPath);
-}
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/write/ISetTemplatePlan.java b/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/write/ISetTemplatePlan.java
deleted file mode 100644
index ef0412d7ac..0000000000
--- a/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/write/ISetTemplatePlan.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.metadata.plan.schemaregion.write;
-
-import org.apache.iotdb.db.metadata.plan.schemaregion.ISchemaRegionPlan;
-import org.apache.iotdb.db.metadata.plan.schemaregion.SchemaRegionPlanType;
-import org.apache.iotdb.db.metadata.plan.schemaregion.SchemaRegionPlanVisitor;
-
-public interface ISetTemplatePlan extends ISchemaRegionPlan {
-
-  @Override
-  default SchemaRegionPlanType getPlanType() {
-    return SchemaRegionPlanType.SET_TEMPLATE;
-  }
-
-  @Override
-  default <R, C> R accept(SchemaRegionPlanVisitor<R, C> visitor, C context) {
-    return visitor.visitSetTemplate(this, context);
-  }
-
-  String getTemplateName();
-
-  void setTemplateName(String templateName);
-
-  String getPrefixPath();
-
-  void setPrefixPath(String prefixPath);
-}
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/write/IUnsetTemplatePlan.java b/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/write/IUnsetTemplatePlan.java
deleted file mode 100644
index d76e98eb83..0000000000
--- a/server/src/main/java/org/apache/iotdb/db/metadata/plan/schemaregion/write/IUnsetTemplatePlan.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.metadata.plan.schemaregion.write;
-
-import org.apache.iotdb.db.metadata.plan.schemaregion.ISchemaRegionPlan;
-import org.apache.iotdb.db.metadata.plan.schemaregion.SchemaRegionPlanType;
-import org.apache.iotdb.db.metadata.plan.schemaregion.SchemaRegionPlanVisitor;
-
-public interface IUnsetTemplatePlan extends ISchemaRegionPlan {
-
-  @Override
-  default SchemaRegionPlanType getPlanType() {
-    return SchemaRegionPlanType.UNSET_TEMPLATE;
-  }
-
-  @Override
-  default <R, C> R accept(SchemaRegionPlanVisitor<R, C> visitor, C context) {
-    return visitor.visitUnsetTemplate(this, context);
-  }
-
-  String getPrefixPath();
-
-  void setPrefixPath(String prefixPath);
-
-  String getTemplateName();
-
-  void setTemplateName(String templateName);
-}
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/ISchemaRegion.java b/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/ISchemaRegion.java
index 6c0a6998f9..c195be9633 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/ISchemaRegion.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/ISchemaRegion.java
@@ -25,20 +25,16 @@ import org.apache.iotdb.commons.exception.MetadataException;
 import org.apache.iotdb.commons.path.MeasurementPath;
 import org.apache.iotdb.commons.path.PartialPath;
 import org.apache.iotdb.commons.path.PathPatternTree;
-import org.apache.iotdb.db.exception.metadata.PathNotExistException;
 import org.apache.iotdb.db.metadata.LocalSchemaProcessor;
 import org.apache.iotdb.db.metadata.mnode.IMNode;
 import org.apache.iotdb.db.metadata.mnode.IMeasurementMNode;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IActivateTemplateInClusterPlan;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.IActivateTemplatePlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IAutoCreateDeviceMNodePlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.ICreateAlignedTimeSeriesPlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.ICreateTimeSeriesPlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IDeactivateTemplatePlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IPreDeactivateTemplatePlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IRollbackPreDeactivateTemplatePlan;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.ISetTemplatePlan;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.IUnsetTemplatePlan;
 import org.apache.iotdb.db.metadata.template.Template;
 import org.apache.iotdb.db.mpp.common.schematree.DeviceSchemaInfo;
 import org.apache.iotdb.db.qp.physical.sys.ShowDevicesPlan;
@@ -314,11 +310,6 @@ public interface ISchemaRegion {
 
   Pair<List<ShowTimeSeriesResult>, Integer> showTimeseries(
       ShowTimeSeriesPlan plan, QueryContext context) throws MetadataException;
-
-  // attention: this path must be a device node
-  List<MeasurementPath> getAllMeasurementByDevicePath(PartialPath devicePath)
-      throws PathNotExistException;
-
   // endregion
   // endregion
 
@@ -407,25 +398,6 @@ public interface ISchemaRegion {
   // endregion
 
   // region Interfaces for Template operations
-  /**
-   * Get all paths set designated template
-   *
-   * @param templateName designated template name, blank string for any template exists
-   * @return paths set
-   */
-  Set<String> getPathsSetTemplate(String templateName) throws MetadataException;
-
-  Set<String> getPathsUsingTemplate(String templateName) throws MetadataException;
-
-  boolean isTemplateAppendable(Template template, List<String> measurements)
-      throws MetadataException;
-
-  void setSchemaTemplate(ISetTemplatePlan plan) throws MetadataException;
-
-  void unsetSchemaTemplate(IUnsetTemplatePlan plan) throws MetadataException;
-
-  void setUsingSchemaTemplate(IActivateTemplatePlan plan) throws MetadataException;
-
   void activateSchemaTemplate(IActivateTemplateInClusterPlan plan, Template template)
       throws MetadataException;
 
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionMemoryImpl.java b/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionMemoryImpl.java
index 0f96d4784f..333ed72ffd 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionMemoryImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionMemoryImpl.java
@@ -35,9 +35,6 @@ import org.apache.iotdb.db.exception.metadata.PathNotExistException;
 import org.apache.iotdb.db.exception.metadata.SchemaDirCreationFailureException;
 import org.apache.iotdb.db.exception.metadata.SeriesNumberOverflowException;
 import org.apache.iotdb.db.exception.metadata.SeriesOverflowException;
-import org.apache.iotdb.db.exception.metadata.template.DifferentTemplateException;
-import org.apache.iotdb.db.exception.metadata.template.NoTemplateOnMNodeException;
-import org.apache.iotdb.db.exception.metadata.template.TemplateIsInUseException;
 import org.apache.iotdb.db.metadata.LocalSchemaProcessor;
 import org.apache.iotdb.db.metadata.MetadataConstant;
 import org.apache.iotdb.db.metadata.idtable.IDTable;
@@ -57,7 +54,6 @@ import org.apache.iotdb.db.metadata.plan.schemaregion.impl.SchemaRegionPlanDeser
 import org.apache.iotdb.db.metadata.plan.schemaregion.impl.SchemaRegionPlanFactory;
 import org.apache.iotdb.db.metadata.plan.schemaregion.impl.SchemaRegionPlanSerializer;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IActivateTemplateInClusterPlan;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.IActivateTemplatePlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IAutoCreateDeviceMNodePlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IChangeAliasPlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IChangeTagOffsetPlan;
@@ -69,13 +65,10 @@ import org.apache.iotdb.db.metadata.plan.schemaregion.write.IPreDeactivateTempla
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IPreDeleteTimeSeriesPlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IRollbackPreDeactivateTemplatePlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IRollbackPreDeleteTimeSeriesPlan;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.ISetTemplatePlan;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.IUnsetTemplatePlan;
 import org.apache.iotdb.db.metadata.rescon.MemoryStatistics;
 import org.apache.iotdb.db.metadata.rescon.SchemaStatisticsManager;
 import org.apache.iotdb.db.metadata.tag.TagManager;
 import org.apache.iotdb.db.metadata.template.Template;
-import org.apache.iotdb.db.metadata.template.TemplateManager;
 import org.apache.iotdb.db.metadata.utils.MetaUtils;
 import org.apache.iotdb.db.mpp.common.schematree.DeviceSchemaInfo;
 import org.apache.iotdb.db.mpp.common.schematree.MeasurementSchemaInfo;
@@ -857,11 +850,6 @@ public class SchemaRegionMemoryImpl implements ISchemaRegion {
 
     IMNode node = measurementMNode.getParent();
 
-    if (node.isUseTemplate() && node.getSchemaTemplate().hasSchema(measurementMNode.getName())) {
-      // measurement represent by template doesn't affect the MTree structure and memory control
-      return;
-    }
-
     mNodeCache.invalidate(node.getPartialPath());
 
     schemaStatisticsManager.deleteTimeseries(1);
@@ -908,11 +896,6 @@ public class SchemaRegionMemoryImpl implements ISchemaRegion {
 
     IMNode node = measurementMNode.getParent();
 
-    if (node.isUseTemplate() && node.getSchemaTemplate().hasSchema(measurementMNode.getName())) {
-      // measurement represent by template doesn't affect the MTree structure and memory control
-      return storageGroupPath;
-    }
-
     mNodeCache.invalidate(node.getPartialPath());
 
     schemaStatisticsManager.deleteTimeseries(1);
@@ -1323,42 +1306,6 @@ public class SchemaRegionMemoryImpl implements ISchemaRegion {
     }
     return new Pair<>(res, ans.right);
   }
-
-  // attention: this path must be a device node
-  @Override
-  public List<MeasurementPath> getAllMeasurementByDevicePath(PartialPath devicePath)
-      throws PathNotExistException {
-    List<MeasurementPath> res = new LinkedList<>();
-    try {
-      IMNode node = mNodeCache.get(devicePath);
-
-      for (IMNode child : node.getChildren().values()) {
-        if (child.isMeasurement()) {
-          IMeasurementMNode measurementMNode = child.getAsMeasurementMNode();
-          res.add(measurementMNode.getMeasurementPath());
-        }
-      }
-
-      // template
-      Template template = node.getUpperTemplate();
-      if (node.isUseTemplate() && template != null) {
-        MeasurementPath measurementPath;
-        for (IMeasurementSchema schema : template.getSchemaMap().values()) {
-          measurementPath =
-              new MeasurementPath(devicePath.concatNode(schema.getMeasurementId()), schema);
-          measurementPath.setUnderAlignedEntity(node.getAsEntityMNode().isAligned());
-          res.add(measurementPath);
-        }
-      }
-    } catch (Exception e) {
-      if (e.getCause() instanceof MetadataException) {
-        throw new PathNotExistException(devicePath.getFullPath());
-      }
-      throw e;
-    }
-
-    return new ArrayList<>(res);
-  }
   // endregion
   // endregion
 
@@ -1713,137 +1660,6 @@ public class SchemaRegionMemoryImpl implements ISchemaRegion {
   // endregion
 
   // region Interfaces and Implementation for Template operations
-  /**
-   * Get all paths set designated template
-   *
-   * @param templateName designated template name, blank string for any template exists
-   * @return paths set
-   */
-  @Override
-  public Set<String> getPathsSetTemplate(String templateName) throws MetadataException {
-    return new HashSet<>(mtree.getPathsSetOnTemplate(templateName));
-  }
-
-  @Override
-  public Set<String> getPathsUsingTemplate(String templateName) throws MetadataException {
-    return new HashSet<>(mtree.getPathsUsingTemplate(templateName));
-  }
-
-  @Override
-  public boolean isTemplateAppendable(Template template, List<String> measurements)
-      throws MetadataException {
-    return mtree.isTemplateAppendable(template, measurements);
-  }
-
-  @Override
-  public synchronized void setSchemaTemplate(ISetTemplatePlan plan) throws MetadataException {
-    // get mnode and update template should be atomic
-    Template template = TemplateManager.getInstance().getTemplate(plan.getTemplateName());
-
-    try {
-      PartialPath path = new PartialPath(plan.getPrefixPath());
-
-      mtree.checkTemplateOnPath(path);
-
-      IMNode node = getDeviceNodeWithAutoCreate(path);
-
-      TemplateManager.getInstance().checkIsTemplateCompatible(template, node);
-      mtree.checkIsTemplateCompatibleWithChild(node, template);
-      node.setSchemaTemplate(template);
-
-      TemplateManager.getInstance()
-          .markSchemaRegion(template, storageGroupFullPath, schemaRegionId);
-
-      // write wal
-      writeToMLog(plan);
-    } catch (IOException e) {
-      throw new MetadataException(e);
-    }
-  }
-
-  @Override
-  public synchronized void unsetSchemaTemplate(IUnsetTemplatePlan plan) throws MetadataException {
-    // get mnode should be atomic
-    try {
-      PartialPath path = new PartialPath(plan.getPrefixPath());
-      IMNode node = mtree.getNodeByPath(path);
-      if (node.getSchemaTemplate() == null) {
-        throw new NoTemplateOnMNodeException(plan.getPrefixPath());
-      } else if (!node.getSchemaTemplate().getName().equals(plan.getTemplateName())) {
-        throw new DifferentTemplateException(plan.getPrefixPath(), plan.getTemplateName());
-      } else if (node.isUseTemplate()) {
-        throw new TemplateIsInUseException(plan.getPrefixPath());
-      }
-      mtree.checkTemplateInUseOnLowerNode(node);
-      Template template = node.getSchemaTemplate();
-      node.setSchemaTemplate(null);
-      TemplateManager.getInstance()
-          .unmarkSchemaRegion(template, storageGroupFullPath, schemaRegionId);
-      // write wal
-      writeToMLog(plan);
-    } catch (IOException e) {
-      throw new MetadataException(e);
-    }
-  }
-
-  @Override
-  public void setUsingSchemaTemplate(IActivateTemplatePlan plan) throws MetadataException {
-    // check whether any template has been set on designated path
-    if (mtree.getTemplateOnPath(plan.getPrefixPath()) == null) {
-      throw new MetadataException(
-          String.format(
-              "Path [%s] has not been set any template.", plan.getPrefixPath().toString()));
-    }
-
-    IMNode node;
-    // the order of SetUsingSchemaTemplatePlan and AutoCreateDeviceMNodePlan cannot be guaranteed
-    // when writing concurrently, so we need a auto-create mechanism here
-    try {
-      node = getDeviceNodeWithAutoCreate(plan.getPrefixPath());
-    } catch (IOException ioException) {
-      throw new MetadataException(ioException);
-    }
-    node = setUsingSchemaTemplate(node);
-  }
-
-  public IMNode setUsingSchemaTemplate(IMNode node) throws MetadataException {
-    // check whether any template has been set on designated path
-    if (node.getUpperTemplate() == null) {
-      throw new MetadataException(
-          String.format("Path [%s] has not been set any template.", node.getFullPath()));
-    }
-
-    // this operation may change mtree structure and node type
-    // invoke mnode.setUseTemplate is invalid
-
-    // check alignment of template and mounted node
-    // if direct measurement exists, node will be replaced
-    IMNode mountedMNode =
-        mtree.checkTemplateAlignmentWithMountedNode(node, node.getUpperTemplate());
-
-    // if has direct measurement (be a EntityNode), to ensure alignment adapt with former node or
-    // template
-    if (mountedMNode.isEntity()) {
-      mountedMNode
-          .getAsEntityMNode()
-          .setAligned(
-              node.isEntity()
-                  ? node.getAsEntityMNode().isAligned()
-                  : node.getUpperTemplate().isDirectAligned());
-    }
-    mountedMNode.setUseTemplate(true);
-
-    if (node != mountedMNode) {
-      mNodeCache.invalidate(mountedMNode.getPartialPath());
-    }
-    try {
-      writeToMLog(SchemaRegionPlanFactory.getActivateTemplatePlan(node.getPartialPath()));
-    } catch (IOException e) {
-      throw new MetadataException(e);
-    }
-    return mountedMNode;
-  }
-
   @Override
   public void activateSchemaTemplate(IActivateTemplateInClusterPlan plan, Template template)
       throws MetadataException {
@@ -2095,39 +1911,6 @@ public class SchemaRegionMemoryImpl implements ISchemaRegion {
       }
     }
 
-    @Override
-    public RecoverOperationResult visitSetTemplate(
-        ISetTemplatePlan setTemplatePlan, SchemaRegionMemoryImpl context) {
-      try {
-        setSchemaTemplate(setTemplatePlan);
-        return RecoverOperationResult.SUCCESS;
-      } catch (MetadataException e) {
-        return new RecoverOperationResult(e);
-      }
-    }
-
-    @Override
-    public RecoverOperationResult visitUnsetTemplate(
-        IUnsetTemplatePlan unsetTemplatePlan, SchemaRegionMemoryImpl context) {
-      try {
-        unsetSchemaTemplate(unsetTemplatePlan);
-        return RecoverOperationResult.SUCCESS;
-      } catch (MetadataException e) {
-        return new RecoverOperationResult(e);
-      }
-    }
-
-    @Override
-    public RecoverOperationResult visitActivateTemplate(
-        IActivateTemplatePlan activateTemplatePlan, SchemaRegionMemoryImpl context) {
-      try {
-        setUsingSchemaTemplate(activateTemplatePlan);
-        return RecoverOperationResult.SUCCESS;
-      } catch (MetadataException e) {
-        return new RecoverOperationResult(e);
-      }
-    }
-
     @Override
     public RecoverOperationResult visitPreDeactivateTemplate(
         IPreDeactivateTemplatePlan preDeactivateTemplatePlan, SchemaRegionMemoryImpl context) {
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionSchemaFileImpl.java b/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionSchemaFileImpl.java
index 8588f34829..1d09544452 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionSchemaFileImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionSchemaFileImpl.java
@@ -34,9 +34,6 @@ import org.apache.iotdb.db.exception.metadata.PathNotExistException;
 import org.apache.iotdb.db.exception.metadata.SchemaDirCreationFailureException;
 import org.apache.iotdb.db.exception.metadata.SeriesNumberOverflowException;
 import org.apache.iotdb.db.exception.metadata.SeriesOverflowException;
-import org.apache.iotdb.db.exception.metadata.template.DifferentTemplateException;
-import org.apache.iotdb.db.exception.metadata.template.NoTemplateOnMNodeException;
-import org.apache.iotdb.db.exception.metadata.template.TemplateIsInUseException;
 import org.apache.iotdb.db.metadata.LocalSchemaProcessor;
 import org.apache.iotdb.db.metadata.MetadataConstant;
 import org.apache.iotdb.db.metadata.idtable.IDTable;
@@ -55,7 +52,6 @@ import org.apache.iotdb.db.metadata.plan.schemaregion.impl.SchemaRegionPlanDeser
 import org.apache.iotdb.db.metadata.plan.schemaregion.impl.SchemaRegionPlanFactory;
 import org.apache.iotdb.db.metadata.plan.schemaregion.impl.SchemaRegionPlanSerializer;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IActivateTemplateInClusterPlan;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.IActivateTemplatePlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IAutoCreateDeviceMNodePlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IChangeAliasPlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IChangeTagOffsetPlan;
@@ -65,13 +61,10 @@ import org.apache.iotdb.db.metadata.plan.schemaregion.write.IDeactivateTemplateP
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IDeleteTimeSeriesPlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IPreDeactivateTemplatePlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IRollbackPreDeactivateTemplatePlan;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.ISetTemplatePlan;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.IUnsetTemplatePlan;
 import org.apache.iotdb.db.metadata.rescon.MemoryStatistics;
 import org.apache.iotdb.db.metadata.rescon.SchemaStatisticsManager;
 import org.apache.iotdb.db.metadata.tag.TagManager;
 import org.apache.iotdb.db.metadata.template.Template;
-import org.apache.iotdb.db.metadata.template.TemplateManager;
 import org.apache.iotdb.db.metadata.utils.MetaUtils;
 import org.apache.iotdb.db.mpp.common.schematree.DeviceSchemaInfo;
 import org.apache.iotdb.db.qp.physical.sys.ShowDevicesPlan;
@@ -943,11 +936,6 @@ public class SchemaRegionSchemaFileImpl implements ISchemaRegion {
 
     IMNode node = measurementMNode.getParent();
 
-    if (node.isUseTemplate() && node.getSchemaTemplate().hasSchema(measurementMNode.getName())) {
-      // measurement represent by template doesn't affect the MTree structure and memory control
-      return;
-    }
-
     mNodeCache.invalidate(node.getPartialPath());
 
     schemaStatisticsManager.deleteTimeseries(1);
@@ -989,11 +977,6 @@ public class SchemaRegionSchemaFileImpl implements ISchemaRegion {
 
     IMNode node = measurementMNode.getParent();
 
-    if (node.isUseTemplate() && node.getSchemaTemplate().hasSchema(measurementMNode.getName())) {
-      // measurement represent by template doesn't affect the MTree structure and memory control
-      return storageGroupPath;
-    }
-
     mNodeCache.invalidate(node.getPartialPath());
 
     schemaStatisticsManager.deleteTimeseries(1);
@@ -1404,42 +1387,6 @@ public class SchemaRegionSchemaFileImpl implements ISchemaRegion {
     }
     return new Pair<>(res, ans.right);
   }
-
-  // attention: this path must be a device node
-  @Override
-  public List<MeasurementPath> getAllMeasurementByDevicePath(PartialPath devicePath)
-      throws PathNotExistException {
-    List<MeasurementPath> res = new LinkedList<>();
-    try {
-      IMNode node = mNodeCache.get(devicePath);
-
-      for (IMNode child : node.getChildren().values()) {
-        if (child.isMeasurement()) {
-          IMeasurementMNode measurementMNode = child.getAsMeasurementMNode();
-          res.add(measurementMNode.getMeasurementPath());
-        }
-      }
-
-      // template
-      Template template = node.getUpperTemplate();
-      if (node.isUseTemplate() && template != null) {
-        MeasurementPath measurementPath;
-        for (IMeasurementSchema schema : template.getSchemaMap().values()) {
-          measurementPath =
-              new MeasurementPath(devicePath.concatNode(schema.getMeasurementId()), schema);
-          measurementPath.setUnderAlignedEntity(node.getAsEntityMNode().isAligned());
-          res.add(measurementPath);
-        }
-      }
-    } catch (Exception e) {
-      if (e.getCause() instanceof MetadataException) {
-        throw new PathNotExistException(devicePath.getFullPath());
-      }
-      throw e;
-    }
-
-    return new ArrayList<>(res);
-  }
   // endregion
   // endregion
 
@@ -1752,108 +1699,6 @@ public class SchemaRegionSchemaFileImpl implements ISchemaRegion {
   // endregion
 
   // region Interfaces and Implementation for Template operations
-  /**
-   * Get all paths set designated template
-   *
-   * @param templateName designated template name, blank string for any template exists
-   * @return paths set
-   */
-  @Override
-  public Set<String> getPathsSetTemplate(String templateName) throws MetadataException {
-    return new HashSet<>(mtree.getPathsSetOnTemplate(templateName));
-  }
-
-  @Override
-  public Set<String> getPathsUsingTemplate(String templateName) throws MetadataException {
-    return new HashSet<>(mtree.getPathsUsingTemplate(templateName));
-  }
-
-  @Override
-  public boolean isTemplateAppendable(Template template, List<String> measurements)
-      throws MetadataException {
-    return mtree.isTemplateAppendable(template, measurements);
-  }
-
-  @Override
-  public synchronized void setSchemaTemplate(ISetTemplatePlan plan) throws MetadataException {
-    // get mnode and update template should be atomic
-    Template template = TemplateManager.getInstance().getTemplate(plan.getTemplateName());
-
-    try {
-      PartialPath path = new PartialPath(plan.getPrefixPath());
-
-      mtree.checkTemplateOnPath(path);
-
-      IMNode node = getDeviceNodeWithAutoCreate(path);
-
-      try {
-        TemplateManager.getInstance().checkIsTemplateCompatible(template, node);
-        mtree.checkIsTemplateCompatibleWithChild(node, template);
-        node.setSchemaTemplate(template);
-        mtree.updateMNode(node);
-      } finally {
-        mtree.unPinMNode(node);
-      }
-
-      TemplateManager.getInstance()
-          .markSchemaRegion(template, storageGroupFullPath, schemaRegionId);
-
-      // write wal
-      writeToMLog(plan);
-    } catch (IOException e) {
-      throw new MetadataException(e);
-    }
-  }
-
-  @Override
-  public synchronized void unsetSchemaTemplate(IUnsetTemplatePlan plan) throws MetadataException {
-    // get mnode should be atomic
-    try {
-      PartialPath path = new PartialPath(plan.getPrefixPath());
-      IMNode node = mtree.getNodeByPath(path);
-      if (node.getSchemaTemplate() == null) {
-        throw new NoTemplateOnMNodeException(plan.getPrefixPath());
-      } else if (!node.getSchemaTemplate().getName().equals(plan.getTemplateName())) {
-        throw new DifferentTemplateException(plan.getPrefixPath(), plan.getTemplateName());
-      } else if (node.isUseTemplate()) {
-        throw new TemplateIsInUseException(plan.getPrefixPath());
-      }
-      mtree.checkTemplateInUseOnLowerNode(node);
-      Template template = node.getSchemaTemplate();
-      node.setSchemaTemplate(null);
-      TemplateManager.getInstance()
-          .unmarkSchemaRegion(template, storageGroupFullPath, schemaRegionId);
-      // write wal
-      writeToMLog(plan);
-    } catch (IOException e) {
-      throw new MetadataException(e);
-    }
-  }
-
-  @Override
-  public void setUsingSchemaTemplate(IActivateTemplatePlan plan) throws MetadataException {
-    // check whether any template has been set on designated path
-    if (mtree.getTemplateOnPath(plan.getPrefixPath()) == null) {
-      throw new MetadataException(
-          String.format(
-              "Path [%s] has not been set any template.", plan.getPrefixPath().toString()));
-    }
-
-    IMNode node;
-    // the order of SetUsingSchemaTemplatePlan and AutoCreateDeviceMNodePlan cannot be guaranteed
-    // when writing concurrently, so we need a auto-create mechanism here
-    try {
-      node = getDeviceNodeWithAutoCreate(plan.getPrefixPath());
-    } catch (IOException ioException) {
-      throw new MetadataException(ioException);
-    }
-    try {
-      node = setUsingSchemaTemplate(node);
-    } finally {
-      mtree.unPinMNode(node);
-    }
-  }
-
   @Override
   public void activateSchemaTemplate(IActivateTemplateInClusterPlan plan, Template template)
       throws MetadataException {
@@ -1924,45 +1769,6 @@ public class SchemaRegionSchemaFileImpl implements ISchemaRegion {
     }
     return result;
   }
-
-  private IMNode setUsingSchemaTemplate(IMNode node) throws MetadataException {
-    // check whether any template has been set on designated path
-    if (node.getUpperTemplate() == null) {
-      throw new MetadataException(
-          String.format("Path [%s] has not been set any template.", node.getFullPath()));
-    }
-
-    // this operation may change mtree structure and node type
-    // invoke mnode.setUseTemplate is invalid
-
-    // check alignment of template and mounted node
-    // if direct measurement exists, node will be replaced
-    IMNode mountedMNode =
-        mtree.checkTemplateAlignmentWithMountedNode(node, node.getUpperTemplate());
-
-    // if has direct measurement (be a EntityNode), to ensure alignment adapt with former node or
-    // template
-    if (mountedMNode.isEntity()) {
-      mountedMNode
-          .getAsEntityMNode()
-          .setAligned(
-              node.isEntity()
-                  ? node.getAsEntityMNode().isAligned()
-                  : node.getUpperTemplate().isDirectAligned());
-    }
-    mountedMNode.setUseTemplate(true);
-    mtree.updateMNode(mountedMNode);
-
-    if (node != mountedMNode) {
-      mNodeCache.invalidate(mountedMNode.getPartialPath());
-    }
-    try {
-      writeToMLog(SchemaRegionPlanFactory.getActivateTemplatePlan(node.getPartialPath()));
-    } catch (IOException e) {
-      throw new MetadataException(e);
-    }
-    return mountedMNode;
-  }
   // endregion
 
   // region Interfaces for Trigger
@@ -2078,38 +1884,5 @@ public class SchemaRegionSchemaFileImpl implements ISchemaRegion {
         return new RecoverOperationResult(e);
       }
     }
-
-    @Override
-    public RecoverOperationResult visitSetTemplate(
-        ISetTemplatePlan setTemplatePlan, SchemaRegionSchemaFileImpl context) {
-      try {
-        setSchemaTemplate(setTemplatePlan);
-        return RecoverOperationResult.SUCCESS;
-      } catch (MetadataException e) {
-        return new RecoverOperationResult(e);
-      }
-    }
-
-    @Override
-    public RecoverOperationResult visitUnsetTemplate(
-        IUnsetTemplatePlan unsetTemplatePlan, SchemaRegionSchemaFileImpl context) {
-      try {
-        unsetSchemaTemplate(unsetTemplatePlan);
-        return RecoverOperationResult.SUCCESS;
-      } catch (MetadataException e) {
-        return new RecoverOperationResult(e);
-      }
-    }
-
-    @Override
-    public RecoverOperationResult visitActivateTemplate(
-        IActivateTemplatePlan activateTemplatePlan, SchemaRegionSchemaFileImpl context) {
-      try {
-        setUsingSchemaTemplate(activateTemplatePlan);
-        return RecoverOperationResult.SUCCESS;
-      } catch (MetadataException e) {
-        return new RecoverOperationResult(e);
-      }
-    }
   }
 }
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/template/TemplateLogReader.java b/server/src/main/java/org/apache/iotdb/db/metadata/template/TemplateLogReader.java
deleted file mode 100644
index 4fc5321afc..0000000000
--- a/server/src/main/java/org/apache/iotdb/db/metadata/template/TemplateLogReader.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.db.metadata.template;
-
-import org.apache.iotdb.db.metadata.logfile.MLogReader;
-import org.apache.iotdb.db.qp.physical.PhysicalPlan;
-
-import java.io.IOException;
-
-public class TemplateLogReader implements AutoCloseable {
-
-  private MLogReader logReader;
-
-  public TemplateLogReader(String schemaDir, String fileName) throws IOException {
-    logReader = new MLogReader(schemaDir, fileName);
-  }
-
-  public boolean hasNext() {
-    return logReader.hasNext();
-  }
-
-  public PhysicalPlan next() {
-    return logReader.next();
-  }
-
-  @Override
-  public void close() {
-    logReader.close();
-  }
-}
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/template/TemplateLogWriter.java b/server/src/main/java/org/apache/iotdb/db/metadata/template/TemplateLogWriter.java
deleted file mode 100644
index de611a5b96..0000000000
--- a/server/src/main/java/org/apache/iotdb/db/metadata/template/TemplateLogWriter.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.db.metadata.template;
-
-import org.apache.iotdb.db.metadata.logfile.MLogWriter;
-import org.apache.iotdb.db.qp.physical.sys.AppendTemplatePlan;
-import org.apache.iotdb.db.qp.physical.sys.CreateTemplatePlan;
-import org.apache.iotdb.db.qp.physical.sys.DropTemplatePlan;
-import org.apache.iotdb.db.qp.physical.sys.PruneTemplatePlan;
-
-import java.io.IOException;
-
-public class TemplateLogWriter {
-
-  private final MLogWriter logWriter;
-
-  public TemplateLogWriter(String schemaDir, String fileName) throws IOException {
-    logWriter = new MLogWriter(schemaDir, fileName);
-  }
-
-  public void createSchemaTemplate(CreateTemplatePlan plan) throws IOException {
-    logWriter.createSchemaTemplate(plan);
-  }
-
-  public void appendSchemaTemplate(AppendTemplatePlan plan) throws IOException {
-    logWriter.appendSchemaTemplate(plan);
-  }
-
-  public void pruneSchemaTemplate(PruneTemplatePlan plan) throws IOException {
-    logWriter.pruneSchemaTemplate(plan);
-  }
-
-  public void dropSchemaTemplate(DropTemplatePlan plan) throws IOException {
-    logWriter.dropSchemaTemplate(plan);
-  }
-
-  public void force() throws IOException {
-    logWriter.force();
-  }
-
-  public void close() throws IOException {
-    logWriter.close();
-  }
-
-  public void clear() throws IOException {
-    logWriter.clear();
-  }
-}
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/template/TemplateManager.java b/server/src/main/java/org/apache/iotdb/db/metadata/template/TemplateManager.java
deleted file mode 100644
index e3398e46bd..0000000000
--- a/server/src/main/java/org/apache/iotdb/db/metadata/template/TemplateManager.java
+++ /dev/null
@@ -1,384 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.db.metadata.template;
-
-import org.apache.iotdb.commons.conf.IoTDBConstant;
-import org.apache.iotdb.commons.consensus.SchemaRegionId;
-import org.apache.iotdb.commons.exception.MetadataException;
-import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.exception.metadata.template.DuplicatedTemplateException;
-import org.apache.iotdb.db.exception.metadata.template.UndefinedTemplateException;
-import org.apache.iotdb.db.metadata.MetadataConstant;
-import org.apache.iotdb.db.metadata.mnode.IMNode;
-import org.apache.iotdb.db.metadata.utils.MetaFormatUtils;
-import org.apache.iotdb.db.qp.physical.PhysicalPlan;
-import org.apache.iotdb.db.qp.physical.sys.AppendTemplatePlan;
-import org.apache.iotdb.db.qp.physical.sys.CreateTemplatePlan;
-import org.apache.iotdb.db.qp.physical.sys.DropTemplatePlan;
-import org.apache.iotdb.db.qp.physical.sys.PruneTemplatePlan;
-import org.apache.iotdb.db.utils.SchemaUtils;
-import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-public class TemplateManager {
-
-  private static final Logger logger = LoggerFactory.getLogger(TemplateManager.class);
-
-  // template name -> template
-  private Map<String, Template> templateMap = new ConcurrentHashMap<>();
-
-  // hash the name of template to record it as fixed length in schema file
-  private Map<Integer, String> templateHashMap = new ConcurrentHashMap<>();
-
-  private final Map<String, Set<Template>> templateUsageInStorageGroup = new ConcurrentHashMap<>();
-
-  private TemplateLogWriter logWriter;
-
-  private boolean isRecover;
-
-  private static class TemplateManagerHolder {
-
-    private TemplateManagerHolder() {
-      // allowed to do nothing
-    }
-
-    private static final TemplateManager INSTANCE = new TemplateManager();
-  }
-
-  public static TemplateManager getInstance() {
-    return TemplateManagerHolder.INSTANCE;
-  }
-
-  private TemplateManager() {}
-
-  public void init() throws IOException {
-    isRecover = true;
-    recoverFromTemplateFile();
-    logWriter =
-        new TemplateLogWriter(
-            IoTDBDescriptor.getInstance().getConfig().getSchemaDir(),
-            MetadataConstant.TEMPLATE_FILE);
-    isRecover = false;
-  }
-
-  private void recoverFromTemplateFile() throws IOException {
-    File logFile =
-        new File(
-            IoTDBDescriptor.getInstance().getConfig().getSchemaDir(),
-            MetadataConstant.TEMPLATE_FILE);
-    if (!logFile.exists()) {
-      return;
-    }
-    try (TemplateLogReader reader =
-        new TemplateLogReader(
-            IoTDBDescriptor.getInstance().getConfig().getSchemaDir(),
-            MetadataConstant.TEMPLATE_FILE)) {
-      PhysicalPlan plan;
-      int idx = 0;
-      while (reader.hasNext()) {
-        try {
-          plan = reader.next();
-          idx++;
-        } catch (Exception e) {
-          logger.error("Parse TemplateFile error at lineNumber {} because:", idx, e);
-          break;
-        }
-        if (plan == null) {
-          continue;
-        }
-        try {
-          switch (plan.getOperatorType()) {
-            case CREATE_TEMPLATE:
-              createSchemaTemplate((CreateTemplatePlan) plan);
-              break;
-            case APPEND_TEMPLATE:
-              appendSchemaTemplate((AppendTemplatePlan) plan);
-              break;
-            case PRUNE_TEMPLATE:
-              pruneSchemaTemplate((PruneTemplatePlan) plan);
-              break;
-            case DROP_TEMPLATE:
-              dropSchemaTemplate((DropTemplatePlan) plan);
-              break;
-            default:
-              throw new IOException(
-                  "Template file corrupted. Read unknown plan type during recover.");
-          }
-        } catch (MetadataException | IOException e) {
-          logger.error(
-              "Can not operate cmd {} in TemplateFile for err:", plan.getOperatorType(), e);
-        }
-      }
-    }
-  }
-
-  public void createSchemaTemplate(CreateTemplatePlan plan) throws MetadataException {
-    List<List<TSDataType>> dataTypes = plan.getDataTypes();
-    List<List<TSEncoding>> encodings = plan.getEncodings();
-    for (int i = 0; i < dataTypes.size(); i++) {
-      for (int j = 0; j < dataTypes.get(i).size(); j++) {
-        SchemaUtils.checkDataTypeWithEncoding(dataTypes.get(i).get(j), encodings.get(i).get(j));
-      }
-    }
-
-    // check schema and measurement name before create template
-    if (plan.getSchemaNames() != null) {
-      for (String schemaNames : plan.getSchemaNames()) {
-        MetaFormatUtils.checkNodeName(schemaNames);
-      }
-    }
-
-    for (List<String> measurements : plan.getMeasurements()) {
-      for (String measurement : measurements) {
-        MetaFormatUtils.checkTimeseries(new PartialPath(measurement));
-      }
-    }
-
-    Template template = new Template(plan);
-    if (templateMap.putIfAbsent(plan.getName(), template) != null) {
-      // already have template
-      throw new MetadataException("Duplicated template name: " + plan.getName());
-    }
-
-    addToHashMap(template);
-
-    try {
-      if (!isRecover) {
-        logWriter.createSchemaTemplate(plan);
-      }
-    } catch (IOException e) {
-      throw new MetadataException(e);
-    }
-  }
-
-  /**
-   * Calculate and store the unique hash code of all existed template. <br>
-   * Collision will be solved by increment now. <br>
-   * 0 is the exceptional value for null template.
-   *
-   * @param template the template to be hashed and added
-   */
-  private void addToHashMap(Template template) {
-    if (templateHashMap.size() >= Integer.MAX_VALUE - 1) {
-      logger.error("Too many templates have been registered.");
-      return;
-    }
-
-    while (templateHashMap.containsKey(template.hashCode())) {
-      if (template.hashCode() == Integer.MAX_VALUE) {
-        template.setRehash(Integer.MIN_VALUE);
-      }
-
-      if (template.hashCode() == 0) {
-        template.setRehash(1);
-      }
-
-      template.setRehash(template.hashCode() + 1);
-    }
-
-    templateHashMap.put(template.hashCode(), template.getName());
-  }
-
-  public void dropSchemaTemplate(DropTemplatePlan plan) throws MetadataException {
-    templateHashMap.remove(templateMap.get(plan.getName()).hashCode());
-    templateMap.remove(plan.getName());
-
-    try {
-      if (!isRecover) {
-        logWriter.dropSchemaTemplate(plan);
-      }
-    } catch (IOException e) {
-      throw new MetadataException(e);
-    }
-  }
-
-  public void appendSchemaTemplate(AppendTemplatePlan plan) throws MetadataException {
-    List<TSDataType> dataTypeList = plan.getDataTypes();
-    List<TSEncoding> encodingList = plan.getEncodings();
-    for (int idx = 0; idx < dataTypeList.size(); idx++) {
-      SchemaUtils.checkDataTypeWithEncoding(dataTypeList.get(idx), encodingList.get(idx));
-    }
-
-    String templateName = plan.getName();
-    Template temp = templateMap.getOrDefault(templateName, null);
-    if (temp != null) {
-      String[] measurements = plan.getMeasurements().toArray(new String[0]);
-      TSDataType[] dataTypes = new TSDataType[measurements.length];
-      TSEncoding[] encodings = new TSEncoding[measurements.length];
-      CompressionType[] compressionTypes = new CompressionType[measurements.length];
-
-      for (int i = 0; i < measurements.length; i++) {
-        dataTypes[i] = plan.getDataTypes().get(i);
-        encodings[i] = plan.getEncodings().get(i);
-        compressionTypes[i] = plan.getCompressors().get(i);
-      }
-
-      if (plan.isAligned()) {
-        temp.addAlignedMeasurements(measurements, dataTypes, encodings, compressionTypes);
-      } else {
-        temp.addUnalignedMeasurements(measurements, dataTypes, encodings, compressionTypes);
-      }
-    } else {
-      throw new MetadataException("Template does not exists:" + plan.getName());
-    }
-
-    try {
-      if (!isRecover) {
-        logWriter.appendSchemaTemplate(plan);
-      }
-    } catch (IOException e) {
-      throw new MetadataException(e);
-    }
-  }
-
-  public void pruneSchemaTemplate(PruneTemplatePlan plan) throws MetadataException {
-    String templateName = plan.getName();
-    Template temp = templateMap.getOrDefault(templateName, null);
-    if (temp != null) {
-      for (int i = 0; i < plan.getPrunedMeasurements().size(); i++) {
-        temp.deleteSeriesCascade(plan.getPrunedMeasurements().get(i));
-      }
-    } else {
-      throw new MetadataException("Template does not exists:" + plan.getName());
-    }
-
-    try {
-      if (!isRecover) {
-        logWriter.pruneSchemaTemplate(plan);
-      }
-    } catch (IOException e) {
-      throw new MetadataException(e);
-    }
-  }
-
-  public Template getTemplate(String templateName) throws UndefinedTemplateException {
-    Template template = templateMap.get(templateName);
-    if (template == null) {
-      throw new UndefinedTemplateException(templateName);
-    }
-    return template;
-  }
-
-  public Template getTemplateFromHash(int hashcode) throws MetadataException {
-    if (!templateHashMap.containsKey(hashcode)) {
-      throw new MetadataException("Invalid hash code for schema template: " + hashcode);
-    }
-    return getTemplate(templateHashMap.get(hashcode));
-  }
-
-  public void setTemplateMap(Map<String, Template> templateMap) {
-    this.templateMap.clear();
-    for (Map.Entry<String, Template> templateEntry : templateMap.entrySet()) {
-      this.templateMap.put(templateEntry.getKey(), templateEntry.getValue());
-      this.addToHashMap(templateEntry.getValue());
-    }
-  }
-
-  public Map<String, Template> getTemplateMap() {
-    return templateMap;
-  }
-
-  public Set<String> getAllTemplateName() {
-    return templateMap.keySet();
-  }
-
-  public void checkIsTemplateCompatible(Template template, IMNode node) throws MetadataException {
-    if (node.getSchemaTemplate() != null) {
-      if (node.getSchemaTemplate().equals(template)) {
-        throw new DuplicatedTemplateException(template.getName());
-      } else {
-        throw new MetadataException("Specified node already has template");
-      }
-    }
-
-    // check alignment
-    if (node.isEntity() && (node.getAsEntityMNode().isAligned() != template.isDirectAligned())) {
-      for (IMNode dNode : template.getDirectNodes()) {
-        if (dNode.isMeasurement()) {
-          throw new MetadataException(
-              String.format(
-                  "Template[%s] and mounted node[%s] has different alignment.",
-                  template.getName(),
-                  node.getFullPath() + IoTDBConstant.PATH_SEPARATOR + dNode.getFullPath()));
-        }
-      }
-    }
-  }
-
-  public void markSchemaRegion(
-      Template template, String storageGroup, SchemaRegionId schemaRegionId) {
-    synchronized (templateUsageInStorageGroup) {
-      if (!templateUsageInStorageGroup.containsKey(storageGroup)) {
-        templateUsageInStorageGroup.putIfAbsent(
-            storageGroup, Collections.synchronizedSet(new HashSet<>()));
-      }
-    }
-    templateUsageInStorageGroup.get(storageGroup).add(template);
-    template.markSchemaRegion(storageGroup, schemaRegionId);
-  }
-
-  public void unmarkSchemaRegion(
-      Template template, String storageGroup, SchemaRegionId schemaRegionId) {
-    Set<Template> usageInStorageGroup = templateUsageInStorageGroup.get(storageGroup);
-    usageInStorageGroup.remove(template);
-    synchronized (templateUsageInStorageGroup) {
-      if (usageInStorageGroup.isEmpty()) {
-        templateUsageInStorageGroup.remove(storageGroup);
-      }
-    }
-    template.unmarkSchemaRegion(storageGroup, schemaRegionId);
-  }
-
-  public void unmarkStorageGroup(Template template, String storageGroup) {
-    synchronized (templateUsageInStorageGroup) {
-      templateUsageInStorageGroup.remove(storageGroup);
-    }
-    template.unmarkStorageGroup(storageGroup);
-  }
-
-  public void forceLog() {
-    try {
-      logWriter.force();
-    } catch (IOException e) {
-      logger.error("Cannot force template log", e);
-    }
-  }
-
-  public void clear() throws IOException {
-    templateMap.clear();
-    templateUsageInStorageGroup.clear();
-    if (logWriter != null) {
-      logWriter.close();
-    }
-  }
-}
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/upgrade/MetadataUpgrader.java b/server/src/main/java/org/apache/iotdb/db/metadata/upgrade/MetadataUpgrader.java
deleted file mode 100644
index 1845e61d61..0000000000
--- a/server/src/main/java/org/apache/iotdb/db/metadata/upgrade/MetadataUpgrader.java
+++ /dev/null
@@ -1,437 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.db.metadata.upgrade;
-
-import org.apache.iotdb.commons.exception.MetadataException;
-import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.db.conf.IoTDBConfig;
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.metadata.LocalSchemaProcessor;
-import org.apache.iotdb.db.metadata.MetadataConstant;
-import org.apache.iotdb.db.metadata.logfile.MLogReader;
-import org.apache.iotdb.db.metadata.mnode.IMNode;
-import org.apache.iotdb.db.metadata.mnode.IMeasurementMNode;
-import org.apache.iotdb.db.metadata.mnode.IStorageGroupMNode;
-import org.apache.iotdb.db.metadata.mnode.InternalMNode;
-import org.apache.iotdb.db.metadata.mnode.MNodeUtils;
-import org.apache.iotdb.db.metadata.mnode.MeasurementMNode;
-import org.apache.iotdb.db.metadata.mnode.StorageGroupMNode;
-import org.apache.iotdb.db.metadata.mnode.container.IMNodeContainer;
-import org.apache.iotdb.db.metadata.mnode.container.MNodeContainerMapImpl;
-import org.apache.iotdb.db.metadata.tag.TagLogFile;
-import org.apache.iotdb.db.qp.physical.PhysicalPlan;
-import org.apache.iotdb.db.qp.physical.sys.ChangeTagOffsetPlan;
-import org.apache.iotdb.db.qp.physical.sys.CreateTimeSeriesPlan;
-import org.apache.iotdb.db.qp.physical.sys.MNodePlan;
-import org.apache.iotdb.db.qp.physical.sys.MeasurementMNodePlan;
-import org.apache.iotdb.db.qp.physical.sys.SetStorageGroupPlan;
-import org.apache.iotdb.db.qp.physical.sys.SetTemplatePlan;
-import org.apache.iotdb.db.qp.physical.sys.StorageGroupMNodePlan;
-import org.apache.iotdb.db.qp.physical.sys.UnsetTemplatePlan;
-import org.apache.iotdb.db.service.IoTDB;
-import org.apache.iotdb.tsfile.utils.Pair;
-import org.apache.iotdb.tsfile.write.schema.IMeasurementSchema;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayDeque;
-import java.util.Deque;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import static org.apache.iotdb.commons.conf.IoTDBConstant.PATH_ROOT;
-import static org.apache.iotdb.commons.conf.IoTDBConstant.PATH_SEPARATOR;
-
-/**
- * IoTDB after v0.13 only support upgrade from v0.12x. This class implements the upgrade program.
- */
-public class MetadataUpgrader {
-
-  private static final Logger logger = LoggerFactory.getLogger(MetadataUpgrader.class);
-
-  private IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
-  private String schemaDirPath = config.getSchemaDir();
-
-  private String mlogFilePath = schemaDirPath + File.separator + MetadataConstant.METADATA_LOG;
-  private File mlogFile = new File(mlogFilePath);
-
-  private String tagFilePath = schemaDirPath + File.separator + MetadataConstant.TAG_LOG;
-  private File tagFile = new File(tagFilePath);
-
-  private String mtreeSnapshotPath =
-      schemaDirPath + File.separator + MetadataConstant.MTREE_SNAPSHOT_OLD_VERSION;
-  private String mtreeSnapshotTmpPath =
-      schemaDirPath + File.separator + MetadataConstant.MTREE_SNAPSHOT_TMP_OLDVERSION;
-  private File snapshotFile = new File(mtreeSnapshotPath);
-  private File snapshotTmpFile = new File(mtreeSnapshotTmpPath);
-
-  LocalSchemaProcessor schemaProcessor = IoTDB.schemaProcessor;
-
-  /**
-   * There are at most four files of old versions:
-   *
-   * <ol>
-   *   <li>snapshot: store the base MTree
-   *   <li>mlog: store the metadata operations based on the exising metadata stored in snapshot
-   *   <li>tag file: store the tag info of timeseries and snapshot and mlog both may hold offsets
-   *       pointing to some part of this file
-   *   <li>tmp snapshot: a tmp file generated during the process of creating snapshot; this file is
-   *       useless
-   * </ol>
-   *
-   * <p>The purpose of upgrader is to recover metadata from the existing files and split and store
-   * them into files in certain database dirs. The upgrader will execute the following steps in
-   * order:
-   *
-   * <ol>
-   *   <li>Deserialize the snapshot and recover the MRTree into memory
-   *   <li>Try create database based on the recovered StorageGroupMNodes and create timeseries based
-   *       on the recovered MeasurementMNode
-   *   <li>Redo the mlog
-   *   <li>rename and backup the files in the same directory, the order is:
-   *       <ol>
-   *         <li>mlog.bin to mlog.bin.bak
-   *         <li>mtree-1.snapshot.bin to mtree-1.snapshot.bin.bak
-   *         <li>tlog.txt to tlog.txt.bak
-   *         <li>mtree-1.snapshot.bin.tmp to mtree-1.snapshot.bin.tmp.bak
-   *       </ol>
-   * </ol>
-   */
-  public static synchronized void upgrade() throws IOException {
-    MetadataUpgrader upgrader = new MetadataUpgrader();
-    logger.info("Start upgrading metadata files.");
-    if (upgrader.clearEnvBeforeUpgrade()) {
-      logger.info("Metadata files have already been upgraded.");
-      return;
-    }
-    IoTDB.configManager.init();
-    try {
-      upgrader.reloadMetadataFromSnapshot();
-      upgrader.redoMLog();
-      upgrader.clearOldFiles();
-      logger.info("Finish upgrading metadata files.");
-    } finally {
-      IoTDB.configManager.clear();
-    }
-  }
-
-  private MetadataUpgrader() {}
-
-  public boolean clearEnvBeforeUpgrade() throws IOException {
-    if (mlogFile.exists()) {
-      // the existence of old mlog means the upgrade was interrupted, thus clear the tmp results.
-      File dir = new File(schemaDirPath);
-      File[] sgDirs = dir.listFiles((dir1, name) -> name.startsWith(PATH_ROOT + PATH_SEPARATOR));
-      if (sgDirs == null) {
-        return false;
-      }
-      for (File sgDir : sgDirs) {
-        File[] sgFiles = sgDir.listFiles();
-        if (sgFiles == null) {
-          continue;
-        }
-        for (File sgFile : sgFiles) {
-          if (!sgFile.delete()) {
-            String errorMessage =
-                String.format(
-                    "Cannot delete file %s in dir %s during metadata upgrade",
-                    sgFile.getName(), sgDir.getName());
-            logger.error(errorMessage);
-            throw new IOException(errorMessage);
-          }
-        }
-      }
-      return false;
-    } else {
-      clearOldFiles();
-      return true;
-    }
-  }
-
-  public void clearOldFiles() throws IOException {
-    backupFile(mlogFile);
-    backupFile(snapshotFile);
-    backupFile(tagFile);
-    backupFile(snapshotTmpFile);
-  }
-
-  private void backupFile(File file) throws IOException {
-    if (!file.exists()) {
-      return;
-    }
-    File backupFile = new File(file.getAbsolutePath() + ".bak");
-    if (backupFile.exists()) {
-      throw new IOException(
-          "The backup file "
-              + backupFile.getAbsolutePath()
-              + " has already existed, please remove it first");
-    }
-    if (!file.renameTo(backupFile)) {
-      String errorMessage =
-          String.format("Cannot backup file %s during metadata upgrade", file.getName());
-      logger.error(errorMessage);
-      throw new IOException(errorMessage);
-    }
-  }
-
-  public void reloadMetadataFromSnapshot() throws IOException {
-    if (!snapshotFile.exists()) {
-      return;
-    }
-    Map<IStorageGroupMNode, List<IMeasurementMNode>> sgMeasurementMap =
-        deserializeFrom(snapshotFile);
-    IMeasurementSchema schema;
-    CreateTimeSeriesPlan createTimeSeriesPlan;
-    Pair<Map<String, String>, Map<String, String>> tagAttributePair;
-    Map<String, String> tags = null;
-    Map<String, String> attributes = null;
-    try (TagLogFile tagLogFile = new TagLogFile(schemaDirPath, MetadataConstant.TAG_LOG)) {
-      for (IStorageGroupMNode storageGroupMNode : sgMeasurementMap.keySet()) {
-        try {
-          schemaProcessor.setStorageGroup(storageGroupMNode.getPartialPath());
-          for (IMeasurementMNode measurementMNode : sgMeasurementMap.get(storageGroupMNode)) {
-            schema = measurementMNode.getSchema();
-            if (measurementMNode.getOffset() != -1) {
-              tagAttributePair =
-                  tagLogFile.read(config.getTagAttributeTotalSize(), measurementMNode.getOffset());
-              if (tagAttributePair != null) {
-                tags = tagAttributePair.left;
-                attributes = tagAttributePair.right;
-              }
-            }
-            createTimeSeriesPlan =
-                new CreateTimeSeriesPlan(
-                    measurementMNode.getPartialPath(),
-                    schema.getType(),
-                    schema.getEncodingType(),
-                    schema.getCompressor(),
-                    schema.getProps(),
-                    tags,
-                    attributes,
-                    measurementMNode.getAlias());
-            schemaProcessor.createTimeseries(createTimeSeriesPlan);
-          }
-        } catch (MetadataException e) {
-          logger.error("Error occurred during recovering metadata from snapshot", e);
-        }
-      }
-    }
-  }
-
-  private Map<IStorageGroupMNode, List<IMeasurementMNode>> deserializeFrom(File mtreeSnapshot)
-      throws IOException {
-    try (MLogReader mLogReader = new MLogReader(mtreeSnapshot)) {
-      Map<IStorageGroupMNode, List<IMeasurementMNode>> sgMeasurementMap = new HashMap<>();
-      deserializeFromReader(mLogReader, sgMeasurementMap);
-      return sgMeasurementMap;
-    }
-  }
-
-  private void deserializeFromReader(
-      MLogReader mLogReader, Map<IStorageGroupMNode, List<IMeasurementMNode>> sgMeasurementMap)
-      throws IOException {
-    Deque<IMNode> nodeStack = new ArrayDeque<>();
-    IMNode node = null;
-    List<IMeasurementMNode> measurementMNodeList = new LinkedList<>();
-    while (mLogReader.hasNext()) {
-      PhysicalPlan plan = mLogReader.next();
-      if (plan == null) {
-        continue;
-      }
-      int childrenSize = 0;
-      if (plan instanceof StorageGroupMNodePlan) {
-        node = StorageGroupMNode.deserializeFrom((StorageGroupMNodePlan) plan);
-        childrenSize = ((StorageGroupMNodePlan) plan).getChildSize();
-        sgMeasurementMap.put(node.getAsStorageGroupMNode(), measurementMNodeList);
-        measurementMNodeList = new LinkedList<>();
-      } else if (plan instanceof MeasurementMNodePlan) {
-        node = MeasurementMNode.deserializeFrom((MeasurementMNodePlan) plan);
-        childrenSize = ((MeasurementMNodePlan) plan).getChildSize();
-        measurementMNodeList.add(node.getAsMeasurementMNode());
-      } else if (plan instanceof MNodePlan) {
-        node = InternalMNode.deserializeFrom((MNodePlan) plan);
-        childrenSize = ((MNodePlan) plan).getChildSize();
-      }
-
-      if (childrenSize != 0) {
-        IMNodeContainer childrenMap = new MNodeContainerMapImpl();
-        for (int i = 0; i < childrenSize; i++) {
-          IMNode child = nodeStack.removeFirst();
-          childrenMap.put(child.getName(), child);
-          if (child.isMeasurement()) {
-            if (!node.isEntity()) {
-              node = MNodeUtils.setToEntity(node);
-            }
-            String alias = child.getAsMeasurementMNode().getAlias();
-            if (alias != null) {
-              node.getAsEntityMNode().addAlias(alias, child.getAsMeasurementMNode());
-            }
-          }
-          child.setParent(node);
-        }
-        node.setChildren(childrenMap);
-      }
-      nodeStack.push(node);
-    }
-    if (node == null || !PATH_ROOT.equals(node.getName())) {
-      logger.error("Snapshot file corrupted!");
-      throw new IOException("Snapshot file corrupted!");
-    }
-  }
-
-  public void redoMLog() throws IOException {
-    PhysicalPlan plan;
-    // templateName -> path -> plan
-    Map<String, Map<String, SetTemplatePlan>> setTemplatePlanAboveSG = new HashMap<>();
-    try (MLogReader mLogReader = new MLogReader(mlogFilePath);
-        TagLogFile tagLogFile = new TagLogFile(schemaDirPath, MetadataConstant.TAG_LOG)) {
-      while (mLogReader.hasNext()) {
-        plan = mLogReader.next();
-        try {
-          switch (plan.getOperatorType()) {
-            case CREATE_TIMESERIES:
-              processCreateTimeseries((CreateTimeSeriesPlan) plan, schemaProcessor, tagLogFile);
-              break;
-            case CHANGE_TAG_OFFSET:
-              processChangeTagOffset((ChangeTagOffsetPlan) plan, schemaProcessor, tagLogFile);
-              break;
-            case SET_STORAGE_GROUP:
-              processSetStorageGroup(
-                  (SetStorageGroupPlan) plan, schemaProcessor, setTemplatePlanAboveSG);
-              break;
-            case SET_TEMPLATE:
-              processSetTemplate((SetTemplatePlan) plan, schemaProcessor, setTemplatePlanAboveSG);
-              break;
-            case UNSET_TEMPLATE:
-              processUnSetTemplate(
-                  (UnsetTemplatePlan) plan, schemaProcessor, setTemplatePlanAboveSG);
-              break;
-            default:
-              schemaProcessor.operation(plan);
-          }
-        } catch (MetadataException e) {
-          logger.error("Error occurred during redo mlog: ", e);
-        }
-      }
-    }
-  }
-
-  private void processCreateTimeseries(
-      CreateTimeSeriesPlan createTimeSeriesPlan,
-      LocalSchemaProcessor schemaProcessor,
-      TagLogFile tagLogFile)
-      throws MetadataException, IOException {
-    long offset;
-    offset = createTimeSeriesPlan.getTagOffset();
-    createTimeSeriesPlan.setTagOffset(-1);
-    createTimeSeriesPlan.setTags(null);
-    createTimeSeriesPlan.setAttributes(null);
-    schemaProcessor.operation(createTimeSeriesPlan);
-    if (offset != -1) {
-      rewriteTagAndAttribute(createTimeSeriesPlan.getPath(), offset, schemaProcessor, tagLogFile);
-    }
-  }
-
-  private void processChangeTagOffset(
-      ChangeTagOffsetPlan changeTagOffsetPlan,
-      LocalSchemaProcessor schemaProcessor,
-      TagLogFile tagLogFile)
-      throws MetadataException, IOException {
-    rewriteTagAndAttribute(
-        changeTagOffsetPlan.getPath(),
-        changeTagOffsetPlan.getOffset(),
-        schemaProcessor,
-        tagLogFile);
-  }
-
-  private void rewriteTagAndAttribute(
-      PartialPath path, long offset, LocalSchemaProcessor schemaProcessor, TagLogFile tagLogFile)
-      throws IOException, MetadataException {
-    Pair<Map<String, String>, Map<String, String>> pair =
-        tagLogFile.read(config.getTagAttributeTotalSize(), offset);
-    schemaProcessor.addTags(pair.left, path);
-    schemaProcessor.addAttributes(pair.right, path);
-  }
-
-  private void processSetStorageGroup(
-      SetStorageGroupPlan setStorageGroupPlan,
-      LocalSchemaProcessor schemaProcessor,
-      Map<String, Map<String, SetTemplatePlan>> setTemplatePlanAboveSG)
-      throws IOException, MetadataException {
-    schemaProcessor.operation(setStorageGroupPlan);
-    String storageGroupPath = setStorageGroupPlan.getPath().getFullPath();
-    String templatePath;
-    for (Map<String, SetTemplatePlan> pathPlanMap : setTemplatePlanAboveSG.values()) {
-      for (SetTemplatePlan setTemplatePlan : pathPlanMap.values()) {
-        templatePath = setTemplatePlan.getPrefixPath();
-        if (storageGroupPath.startsWith(templatePath)) {
-          schemaProcessor.setSchemaTemplate(
-              new SetTemplatePlan(setTemplatePlan.getTemplateName(), storageGroupPath));
-        }
-      }
-    }
-  }
-
-  private void processSetTemplate(
-      SetTemplatePlan setTemplatePlan,
-      LocalSchemaProcessor schemaProcessor,
-      Map<String, Map<String, SetTemplatePlan>> setTemplatePlanAboveSG)
-      throws MetadataException {
-    PartialPath path = new PartialPath(setTemplatePlan.getPrefixPath());
-    List<PartialPath> storageGroupPathList = schemaProcessor.getMatchedStorageGroups(path, true);
-    if (storageGroupPathList.size() > 1 || !path.equals(storageGroupPathList.get(0))) {
-      String templateName = setTemplatePlan.getTemplateName();
-      if (!setTemplatePlanAboveSG.containsKey(templateName)) {
-        setTemplatePlanAboveSG.put(templateName, new HashMap<>());
-      }
-      setTemplatePlanAboveSG
-          .get(templateName)
-          .put(setTemplatePlan.getPrefixPath(), setTemplatePlan);
-    }
-
-    for (PartialPath storageGroupPath : storageGroupPathList) {
-      schemaProcessor.setSchemaTemplate(
-          new SetTemplatePlan(setTemplatePlan.getTemplateName(), storageGroupPath.getFullPath()));
-    }
-  }
-
-  private void processUnSetTemplate(
-      UnsetTemplatePlan unsetTemplatePlan,
-      LocalSchemaProcessor schemaProcessor,
-      Map<String, Map<String, SetTemplatePlan>> setTemplatePlanAboveSG)
-      throws MetadataException {
-    PartialPath path = new PartialPath(unsetTemplatePlan.getPrefixPath());
-    List<PartialPath> storageGroupPathList = schemaProcessor.getMatchedStorageGroups(path, true);
-    if (storageGroupPathList.size() > 1 || !path.equals(storageGroupPathList.get(0))) {
-      setTemplatePlanAboveSG
-          .get(unsetTemplatePlan.getTemplateName())
-          .remove(unsetTemplatePlan.getPrefixPath());
-    }
-    for (PartialPath storageGroupPath : storageGroupPathList) {
-      schemaProcessor.unsetSchemaTemplate(
-          new UnsetTemplatePlan(
-              storageGroupPath.getFullPath(), unsetTemplatePlan.getTemplateName()));
-    }
-  }
-}
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java b/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
index 05a90db802..3c002f3eef 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
@@ -89,8 +89,6 @@ import org.apache.iotdb.tsfile.read.common.RowRecord;
 import org.apache.iotdb.tsfile.read.query.dataset.EmptyDataSet;
 import org.apache.iotdb.tsfile.read.query.dataset.QueryDataSet;
 import org.apache.iotdb.tsfile.utils.Binary;
-import org.apache.iotdb.tsfile.utils.Pair;
-import org.apache.iotdb.tsfile.write.schema.IMeasurementSchema;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -634,86 +632,34 @@ public class PlanExecutor implements IPlanExecutor {
   }
 
   private QueryDataSet processShowSchemaTemplates() {
-    ListDataSet listDataSet =
-        new ListDataSet(
-            Collections.singletonList(new PartialPath(COLUMN_SCHEMA_TEMPLATE, false)),
-            Collections.singletonList(TSDataType.TEXT));
-    Set<String> allTemplates = IoTDB.schemaProcessor.getAllTemplates();
-    for (String templateName : allTemplates) {
-      RowRecord rowRecord = new RowRecord(0); // ignore timestamp
-      rowRecord.addField(Binary.valueOf(templateName), TSDataType.TEXT);
-      listDataSet.putRecord(rowRecord);
-    }
-    return listDataSet;
+    return new ListDataSet(
+        Collections.singletonList(new PartialPath(COLUMN_SCHEMA_TEMPLATE, false)),
+        Collections.singletonList(TSDataType.TEXT));
   }
 
   private QueryDataSet processShowNodesInSchemaTemplate(ShowNodesInTemplatePlan showPlan)
       throws QueryProcessException {
-    ListDataSet listDataSet =
-        new ListDataSet(
-            Arrays.asList(
-                new PartialPath(COLUMN_CHILD_NODES, false),
-                new PartialPath(COLUMN_TIMESERIES_DATATYPE, false),
-                new PartialPath(COLUMN_TIMESERIES_ENCODING, false),
-                new PartialPath(COLUMN_TIMESERIES_COMPRESSION, false)),
-            Arrays.asList(TSDataType.TEXT, TSDataType.TEXT, TSDataType.TEXT, TSDataType.TEXT));
-    try {
-      List<Pair<String, IMeasurementSchema>> measurements =
-          IoTDB.schemaProcessor.getSchemasInTemplate(showPlan.getTemplateName(), "");
-      for (Pair<String, IMeasurementSchema> measurement : measurements) {
-        RowRecord rowRecord = new RowRecord(0); // ignore timestamp
-        rowRecord.addField(Binary.valueOf(measurement.left), TSDataType.TEXT);
-
-        IMeasurementSchema measurementSchema = measurement.right;
-        rowRecord.addField(Binary.valueOf(measurementSchema.getType().toString()), TSDataType.TEXT);
-        rowRecord.addField(
-            Binary.valueOf(measurementSchema.getEncodingType().toString()), TSDataType.TEXT);
-        rowRecord.addField(
-            Binary.valueOf(measurementSchema.getCompressor().toString()), TSDataType.TEXT);
-        listDataSet.putRecord(rowRecord);
-      }
-    } catch (MetadataException e) {
-      throw new QueryProcessException(e);
-    }
-    return listDataSet;
+    return new ListDataSet(
+        Arrays.asList(
+            new PartialPath(COLUMN_CHILD_NODES, false),
+            new PartialPath(COLUMN_TIMESERIES_DATATYPE, false),
+            new PartialPath(COLUMN_TIMESERIES_ENCODING, false),
+            new PartialPath(COLUMN_TIMESERIES_COMPRESSION, false)),
+        Arrays.asList(TSDataType.TEXT, TSDataType.TEXT, TSDataType.TEXT, TSDataType.TEXT));
   }
 
   private QueryDataSet processShowPathsUsingSchemaTemplate(ShowPathsUsingTemplatePlan showPlan)
       throws QueryProcessException {
-    ListDataSet listDataSet =
-        new ListDataSet(
-            Collections.singletonList(new PartialPath(COLUMN_CHILD_PATHS, false)),
-            Collections.singletonList(TSDataType.TEXT));
-    try {
-      Set<String> paths = IoTDB.schemaProcessor.getPathsUsingTemplate(showPlan.getTemplateName());
-      for (String path : paths) {
-        RowRecord rowRecord = new RowRecord(0); // ignore timestamp
-        rowRecord.addField(Binary.valueOf(path), TSDataType.TEXT);
-        listDataSet.putRecord(rowRecord);
-      }
-    } catch (MetadataException e) {
-      throw new QueryProcessException(e);
-    }
-    return listDataSet;
+    return new ListDataSet(
+        Collections.singletonList(new PartialPath(COLUMN_CHILD_PATHS, false)),
+        Collections.singletonList(TSDataType.TEXT));
   }
 
   private QueryDataSet processShowPathsSetSchemaTemplate(ShowPathsSetTemplatePlan showPlan)
       throws QueryProcessException {
-    ListDataSet listDataSet =
-        new ListDataSet(
-            Collections.singletonList(new PartialPath(COLUMN_CHILD_PATHS, false)),
-            Collections.singletonList(TSDataType.TEXT));
-    try {
-      Set<String> paths = IoTDB.schemaProcessor.getPathsSetTemplate(showPlan.getTemplateName());
-      for (String path : paths) {
-        RowRecord rowRecord = new RowRecord(0); // ignore timestamp
-        rowRecord.addField(Binary.valueOf(path), TSDataType.TEXT);
-        listDataSet.putRecord(rowRecord);
-      }
-    } catch (MetadataException e) {
-      throw new QueryProcessException(e);
-    }
-    return listDataSet;
+    return new ListDataSet(
+        Collections.singletonList(new PartialPath(COLUMN_CHILD_PATHS, false)),
+        Collections.singletonList(TSDataType.TEXT));
   }
 
   private void appendNativeFunctions(ListDataSet listDataSet) {
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/ActivateTemplatePlan.java b/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/ActivateTemplatePlan.java
index 6c893a985d..7e57a4cf33 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/ActivateTemplatePlan.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/ActivateTemplatePlan.java
@@ -21,7 +21,6 @@ package org.apache.iotdb.db.qp.physical.sys;
 
 import org.apache.iotdb.commons.exception.IllegalPathException;
 import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.IActivateTemplatePlan;
 import org.apache.iotdb.db.qp.logical.Operator.OperatorType;
 import org.apache.iotdb.db.qp.physical.PhysicalPlan;
 import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
@@ -34,7 +33,7 @@ import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.List;
 
-public class ActivateTemplatePlan extends PhysicalPlan implements IActivateTemplatePlan {
+public class ActivateTemplatePlan extends PhysicalPlan {
 
   private static final Logger logger = LoggerFactory.getLogger(ActivateTemplatePlan.class);
   PartialPath prefixPath;
@@ -57,7 +56,6 @@ public class ActivateTemplatePlan extends PhysicalPlan implements IActivateTempl
     return prefixPath;
   }
 
-  @Override
   public void setPrefixPath(PartialPath prefixPath) {
     this.prefixPath = prefixPath;
   }
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/SetTemplatePlan.java b/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/SetTemplatePlan.java
index 6a216ac323..5ab66113e8 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/SetTemplatePlan.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/SetTemplatePlan.java
@@ -23,7 +23,6 @@ import org.apache.iotdb.commons.conf.IoTDBConstant;
 import org.apache.iotdb.commons.exception.IllegalPathException;
 import org.apache.iotdb.commons.path.PartialPath;
 import org.apache.iotdb.commons.utils.PathUtils;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.ISetTemplatePlan;
 import org.apache.iotdb.db.qp.logical.Operator.OperatorType;
 import org.apache.iotdb.db.qp.physical.PhysicalPlan;
 import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
@@ -33,7 +32,7 @@ import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.List;
 
-public class SetTemplatePlan extends PhysicalPlan implements ISetTemplatePlan {
+public class SetTemplatePlan extends PhysicalPlan {
   String templateName;
   String prefixPath;
 
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/UnsetTemplatePlan.java b/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/UnsetTemplatePlan.java
index 252790d4a1..f10560801e 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/UnsetTemplatePlan.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/UnsetTemplatePlan.java
@@ -24,7 +24,6 @@ import org.apache.iotdb.commons.conf.IoTDBConstant;
 import org.apache.iotdb.commons.exception.IllegalPathException;
 import org.apache.iotdb.commons.path.PartialPath;
 import org.apache.iotdb.commons.utils.PathUtils;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.IUnsetTemplatePlan;
 import org.apache.iotdb.db.qp.logical.Operator;
 import org.apache.iotdb.db.qp.physical.PhysicalPlan;
 import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
@@ -34,7 +33,7 @@ import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.List;
 
-public class UnsetTemplatePlan extends PhysicalPlan implements IUnsetTemplatePlan {
+public class UnsetTemplatePlan extends PhysicalPlan {
 
   String prefixPath;
   String templateName;
diff --git a/server/src/main/java/org/apache/iotdb/db/service/thrift/impl/TSServiceImpl.java b/server/src/main/java/org/apache/iotdb/db/service/thrift/impl/TSServiceImpl.java
index 995d597188..3a524b0fe1 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/thrift/impl/TSServiceImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/thrift/impl/TSServiceImpl.java
@@ -39,7 +39,6 @@ import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.conf.OperationType;
 import org.apache.iotdb.db.exception.StorageEngineException;
 import org.apache.iotdb.db.exception.query.QueryProcessException;
-import org.apache.iotdb.db.metadata.template.TemplateQueryType;
 import org.apache.iotdb.db.qp.logical.Operator.OperatorType;
 import org.apache.iotdb.db.qp.physical.PhysicalPlan;
 import org.apache.iotdb.db.qp.physical.crud.QueryPlan;
@@ -359,65 +358,6 @@ public class TSServiceImpl implements IClientRPCServiceWithHandler {
     return IoTDB.schemaProcessor.getSeriesType(path);
   }
 
-  private boolean executeMultiTimeSeriesPlan(
-      CreateMultiTimeSeriesPlan multiPlan, List<TSStatus> result) {
-    long t1 = System.currentTimeMillis();
-    TSStatus tsStatus = executeNonQueryPlan(multiPlan);
-    addOperationLatency(Operation.EXECUTE_MULTI_TIMESERIES_PLAN_IN_BATCH, t1);
-
-    int startIndex = result.size();
-    if (startIndex > 0) {
-      startIndex = startIndex - 1;
-    }
-    for (int k = 0; k < multiPlan.getPaths().size(); k++) {
-      result.add(RpcUtils.SUCCESS_STATUS);
-    }
-    if (tsStatus.subStatus != null) {
-      for (Entry<Integer, TSStatus> entry : multiPlan.getResults().entrySet()) {
-        result.set(startIndex + entry.getKey(), entry.getValue());
-      }
-    }
-    return tsStatus.getCode() == RpcUtils.SUCCESS_STATUS.getCode();
-  }
-
-  private void initMultiTimeSeriesPlan(CreateMultiTimeSeriesPlan multiPlan) {
-    if (multiPlan.getPaths() == null) {
-      List<PartialPath> paths = new ArrayList<>();
-      List<TSDataType> tsDataTypes = new ArrayList<>();
-      List<TSEncoding> tsEncodings = new ArrayList<>();
-      List<CompressionType> tsCompressionTypes = new ArrayList<>();
-      List<Map<String, String>> tagsList = new ArrayList<>();
-      List<Map<String, String>> attributesList = new ArrayList<>();
-      List<String> aliasList = new ArrayList<>();
-      multiPlan.setPaths(paths);
-      multiPlan.setDataTypes(tsDataTypes);
-      multiPlan.setEncodings(tsEncodings);
-      multiPlan.setCompressors(tsCompressionTypes);
-      multiPlan.setTags(tagsList);
-      multiPlan.setAttributes(attributesList);
-      multiPlan.setAlias(aliasList);
-    }
-  }
-
-  private void setMultiTimeSeriesPlan(
-      CreateMultiTimeSeriesPlan multiPlan, CreateTimeSeriesPlan createTimeSeriesPlan) {
-    PartialPath path = createTimeSeriesPlan.getPath();
-    TSDataType type = createTimeSeriesPlan.getDataType();
-    TSEncoding encoding = createTimeSeriesPlan.getEncoding();
-    CompressionType compressor = createTimeSeriesPlan.getCompressor();
-    Map<String, String> tags = createTimeSeriesPlan.getTags();
-    Map<String, String> attributes = createTimeSeriesPlan.getAttributes();
-    String alias = createTimeSeriesPlan.getAlias();
-
-    multiPlan.getPaths().add(path);
-    multiPlan.getDataTypes().add(type);
-    multiPlan.getEncodings().add(encoding);
-    multiPlan.getCompressors().add(compressor);
-    multiPlan.getTags().add(tags);
-    multiPlan.getAttributes().add(attributes);
-    multiPlan.getAlias().add(alias);
-  }
-
   @Override
   public TSStatus executeBatchStatement(TSExecuteBatchStatementReq req) {
     return null;
@@ -1366,49 +1306,6 @@ public class TSServiceImpl implements IClientRPCServiceWithHandler {
 
   @Override
   public TSQueryTemplateResp querySchemaTemplate(TSQueryTemplateReq req) {
-    try {
-      TSQueryTemplateResp resp = new TSQueryTemplateResp();
-      String path;
-      switch (TemplateQueryType.values()[req.getQueryType()]) {
-        case COUNT_MEASUREMENTS:
-          resp.setQueryType(TemplateQueryType.COUNT_MEASUREMENTS.ordinal());
-          resp.setCount(IoTDB.schemaProcessor.countMeasurementsInTemplate(req.name));
-          break;
-        case IS_MEASUREMENT:
-          path = req.getMeasurement();
-          resp.setQueryType(TemplateQueryType.IS_MEASUREMENT.ordinal());
-          resp.setResult(IoTDB.schemaProcessor.isMeasurementInTemplate(req.name, path));
-          break;
-        case PATH_EXIST:
-          path = req.getMeasurement();
-          resp.setQueryType(TemplateQueryType.PATH_EXIST.ordinal());
-          resp.setResult(IoTDB.schemaProcessor.isPathExistsInTemplate(req.name, path));
-          break;
-        case SHOW_MEASUREMENTS:
-          path = req.getMeasurement();
-          resp.setQueryType(TemplateQueryType.SHOW_MEASUREMENTS.ordinal());
-          resp.setMeasurements(IoTDB.schemaProcessor.getMeasurementsInTemplate(req.name, path));
-          break;
-        case SHOW_TEMPLATES:
-          resp.setQueryType(TemplateQueryType.SHOW_TEMPLATES.ordinal());
-          resp.setMeasurements(new ArrayList<>(IoTDB.schemaProcessor.getAllTemplates()));
-          break;
-        case SHOW_SET_TEMPLATES:
-          path = req.getName();
-          resp.setQueryType(TemplateQueryType.SHOW_SET_TEMPLATES.ordinal());
-          resp.setMeasurements(new ArrayList<>(IoTDB.schemaProcessor.getPathsSetTemplate(path)));
-          break;
-        case SHOW_USING_TEMPLATES:
-          path = req.getName();
-          resp.setQueryType(TemplateQueryType.SHOW_USING_TEMPLATES.ordinal());
-          resp.setMeasurements(new ArrayList<>(IoTDB.schemaProcessor.getPathsUsingTemplate(path)));
-          break;
-      }
-      resp.setStatus(RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS, "Execute successfully"));
-      return resp;
-    } catch (MetadataException e) {
-      LOGGER.error("fail to query schema template because: " + e);
-    }
     return null;
   }
 
diff --git a/server/src/test/java/org/apache/iotdb/db/metadata/SchemaBasicTest.java b/server/src/test/java/org/apache/iotdb/db/metadata/SchemaBasicTest.java
index 5e77bf4c8a..27755c8c3c 100644
--- a/server/src/test/java/org/apache/iotdb/db/metadata/SchemaBasicTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/metadata/SchemaBasicTest.java
@@ -20,44 +20,31 @@ package org.apache.iotdb.db.metadata;
 
 import org.apache.iotdb.commons.exception.IllegalPathException;
 import org.apache.iotdb.commons.exception.MetadataException;
-import org.apache.iotdb.commons.path.MeasurementPath;
 import org.apache.iotdb.commons.path.PartialPath;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.exception.metadata.PathNotExistException;
 import org.apache.iotdb.db.exception.metadata.StorageGroupAlreadySetException;
 import org.apache.iotdb.db.exception.metadata.StorageGroupNotSetException;
-import org.apache.iotdb.db.metadata.mnode.IMNode;
-import org.apache.iotdb.db.metadata.mnode.IMeasurementMNode;
-import org.apache.iotdb.db.metadata.template.Template;
 import org.apache.iotdb.db.metadata.utils.MetaUtils;
-import org.apache.iotdb.db.qp.physical.sys.ActivateTemplatePlan;
-import org.apache.iotdb.db.qp.physical.sys.AppendTemplatePlan;
 import org.apache.iotdb.db.qp.physical.sys.CreateAlignedTimeSeriesPlan;
 import org.apache.iotdb.db.qp.physical.sys.CreateTemplatePlan;
 import org.apache.iotdb.db.qp.physical.sys.CreateTimeSeriesPlan;
-import org.apache.iotdb.db.qp.physical.sys.SetTemplatePlan;
 import org.apache.iotdb.db.qp.physical.sys.ShowTimeSeriesPlan;
-import org.apache.iotdb.db.qp.physical.sys.UnsetTemplatePlan;
 import org.apache.iotdb.db.query.context.QueryContext;
 import org.apache.iotdb.db.query.dataset.ShowResult;
 import org.apache.iotdb.db.query.dataset.ShowTimeSeriesResult;
 import org.apache.iotdb.db.service.IoTDB;
 import org.apache.iotdb.db.utils.EnvironmentUtils;
 import org.apache.iotdb.tsfile.common.conf.TSFileDescriptor;
-import org.apache.iotdb.tsfile.common.constant.TsFileConstant;
 import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
-import org.apache.iotdb.tsfile.write.schema.IMeasurementSchema;
-import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
 
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -72,8 +59,6 @@ import java.util.stream.Collectors;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -263,37 +248,6 @@ public abstract class SchemaBasicTest {
       fail(e.getMessage());
     }
     assertFalse(schemaProcessor.isPathExist(new PartialPath("root.`1`")));
-
-    assertFalse(schemaProcessor.isPathExist(new PartialPath("root.template0")));
-    assertFalse(schemaProcessor.isPathExist(new PartialPath("root.template0.d1")));
-
-    try {
-      schemaProcessor.createTimeseries(
-          new PartialPath("root.template0.d2"),
-          TSDataType.INT32,
-          TSEncoding.RLE,
-          TSFileDescriptor.getInstance().getConfig().getCompressor(),
-          Collections.emptyMap());
-    } catch (MetadataException e) {
-      e.printStackTrace();
-      fail(e.getMessage());
-    }
-
-    try {
-      schemaProcessor.createSchemaTemplate(getCreateTemplatePlan());
-      schemaProcessor.setSchemaTemplate(new SetTemplatePlan("template1", "root.template0"));
-      schemaProcessor.setUsingSchemaTemplate(
-          new ActivateTemplatePlan(new PartialPath("root.template0.d1")));
-    } catch (MetadataException e) {
-      e.printStackTrace();
-      fail(e.getMessage());
-    }
-
-    assertTrue(schemaProcessor.isPathExist(new PartialPath("root.template0.d1")));
-    assertTrue(schemaProcessor.isPathExist(new PartialPath("root.template0.d1.s11")));
-    assertFalse(schemaProcessor.isPathExist(new PartialPath("root.template0.d2.s11")));
-    assertTrue(schemaProcessor.isPathExist(new PartialPath("root.template0.d1.vector")));
-    assertTrue(schemaProcessor.isPathExist(new PartialPath("root.template0.d1.vector.s0")));
   }
 
   /**
@@ -892,186 +846,6 @@ public abstract class SchemaBasicTest {
     }
   }
 
-  @Test
-  @Ignore
-  public void testTemplate() throws MetadataException {
-    CreateTemplatePlan plan = getCreateTemplatePlan();
-
-    LocalSchemaProcessor schemaProcessor = IoTDB.schemaProcessor;
-    schemaProcessor.createSchemaTemplate(plan);
-
-    // set device template
-    SetTemplatePlan setTemplatePlan = new SetTemplatePlan("template1", "root.sg1.d1");
-
-    schemaProcessor.setSchemaTemplate(setTemplatePlan);
-
-    schemaProcessor.setUsingSchemaTemplate(
-        new ActivateTemplatePlan(new PartialPath("root.sg1.d1")));
-    IMNode node = schemaProcessor.getDeviceNode(new PartialPath("root.sg1.d1"));
-
-    MeasurementSchema s11 =
-        new MeasurementSchema("s11", TSDataType.INT64, TSEncoding.RLE, CompressionType.SNAPPY);
-    assertNotNull(node.getSchemaTemplate());
-
-    Set<String> allSchema = new HashSet<>();
-    for (IMeasurementSchema schema : node.getSchemaTemplate().getSchemaMap().values()) {
-      allSchema.add(
-          "root.sg1.d1.vector" + TsFileConstant.PATH_SEPARATOR + schema.getMeasurementId());
-    }
-    for (MeasurementPath measurementPath :
-        schemaProcessor.getMeasurementPaths(new PartialPath("root.sg1.**"))) {
-      allSchema.remove(measurementPath.toString());
-    }
-    allSchema.remove("root.sg1.d1.vector.s11");
-    assertTrue(allSchema.isEmpty());
-
-    IMeasurementMNode mNode =
-        schemaProcessor.getMeasurementMNode(new PartialPath("root.sg1.d1.s11"));
-    IMeasurementMNode mNode2 =
-        schemaProcessor.getMeasurementMNode(new PartialPath("root.sg1.d1.vector.s2"));
-    assertNotNull(mNode);
-    assertEquals(mNode.getSchema(), s11);
-    assertNotNull(mNode2);
-    assertEquals(
-        mNode2.getSchema(),
-        schemaProcessor.getTemplate("template1").getSchemaMap().get("vector.s2"));
-
-    try {
-      schemaProcessor.getMeasurementMNode(new PartialPath("root.sg1.d1.s100"));
-      fail();
-    } catch (PathNotExistException e) {
-      assertEquals("Path [root.sg1.d1.s100] does not exist", e.getMessage());
-    }
-  }
-
-  @Test
-  public void testTemplateWithUnsupportedTypeEncoding() throws MetadataException {
-    CreateTemplatePlan plan;
-    List<List<String>> measurementList = new ArrayList<>();
-    measurementList.add(Collections.singletonList("d1.s1"));
-    measurementList.add(Collections.singletonList("s2"));
-    measurementList.add(Arrays.asList("GPS.x", "GPS.y"));
-
-    List<List<TSDataType>> dataTypeList = new ArrayList<>();
-    dataTypeList.add(Collections.singletonList(TSDataType.INT32));
-    dataTypeList.add(Collections.singletonList(TSDataType.INT32));
-    dataTypeList.add(Arrays.asList(TSDataType.TEXT, TSDataType.FLOAT));
-
-    List<List<TSEncoding>> encodingList = new ArrayList<>();
-    encodingList.add(Collections.singletonList(TSEncoding.GORILLA));
-    encodingList.add(Collections.singletonList(TSEncoding.GORILLA));
-    encodingList.add(Arrays.asList(TSEncoding.RLE, TSEncoding.RLE));
-
-    List<List<CompressionType>> compressionTypes = new ArrayList<>();
-    compressionTypes.add(Collections.singletonList(CompressionType.GZIP));
-    compressionTypes.add(Collections.singletonList(CompressionType.SNAPPY));
-    compressionTypes.add(Arrays.asList(CompressionType.SNAPPY, CompressionType.SNAPPY));
-
-    try {
-      plan =
-          new CreateTemplatePlan(
-              "treeTemplate", measurementList, dataTypeList, encodingList, compressionTypes);
-      IoTDB.schemaProcessor.createSchemaTemplate(plan);
-    } catch (MetadataException e) {
-      assertEquals("encoding RLE does not support TEXT", e.getMessage());
-    }
-
-    dataTypeList.get(2).set(0, TSDataType.FLOAT);
-    CreateTemplatePlan planb =
-        new CreateTemplatePlan(
-            "treeTemplate", measurementList, dataTypeList, encodingList, compressionTypes);
-
-    IoTDB.schemaProcessor.createSchemaTemplate(planb);
-    Template template = IoTDB.schemaProcessor.getTemplate("treeTemplate");
-    assertEquals("[d1.s1, GPS.x, GPS.y, s2]", template.getAllMeasurementsPaths().toString());
-
-    List<String> appendMeasurements = Arrays.asList("a1", "a2");
-    List<TSDataType> appendDataTypes = Arrays.asList(TSDataType.TEXT, TSDataType.FLOAT);
-    List<TSEncoding> appendEncodings = Arrays.asList(TSEncoding.RLE, TSEncoding.RLE);
-    List<CompressionType> appendCompressor =
-        Arrays.asList(CompressionType.SNAPPY, CompressionType.LZ4);
-    AppendTemplatePlan plana =
-        new AppendTemplatePlan(
-            "treeTemplate",
-            false,
-            appendMeasurements,
-            appendDataTypes,
-            appendEncodings,
-            appendCompressor);
-    try {
-      IoTDB.schemaProcessor.appendSchemaTemplate(plana);
-    } catch (MetadataException e) {
-      assertEquals("encoding RLE does not support TEXT", e.getMessage());
-    }
-
-    appendDataTypes.set(0, TSDataType.FLOAT);
-    AppendTemplatePlan planab =
-        new AppendTemplatePlan(
-            "treeTemplate",
-            false,
-            appendMeasurements,
-            appendDataTypes,
-            appendEncodings,
-            appendCompressor);
-    IoTDB.schemaProcessor.appendSchemaTemplate(planab);
-    assertEquals(
-        "[a1, a2, d1.s1, GPS.x, GPS.y, s2]", template.getAllMeasurementsPaths().toString());
-  }
-
-  @Test
-  public void testTemplateInnerTree() throws MetadataException {
-    CreateTemplatePlan plan = getTreeTemplatePlan();
-    Template template;
-    LocalSchemaProcessor schemaProcessor = IoTDB.schemaProcessor;
-
-    schemaProcessor.createSchemaTemplate(plan);
-    template = schemaProcessor.getTemplate("treeTemplate");
-    assertEquals(4, template.getMeasurementsCount());
-    assertEquals("d1", template.getPathNodeInTemplate("d1").getName());
-    assertNull(template.getPathNodeInTemplate("notExists"));
-    assertEquals("[GPS]", template.getAllAlignedPrefix().toString());
-
-    String[] alignedMeasurements = {"`to`.be.prefix.s1", "`to`.be.prefix.s2"};
-    TSDataType[] dataTypes = {TSDataType.INT32, TSDataType.INT32};
-    TSEncoding[] encodings = {TSEncoding.RLE, TSEncoding.RLE};
-    CompressionType[] compressionTypes = {CompressionType.SNAPPY, CompressionType.SNAPPY};
-    template.addAlignedMeasurements(alignedMeasurements, dataTypes, encodings, compressionTypes);
-
-    assertEquals("[to.be.prefix, GPS]", template.getAllAlignedPrefix().toString());
-    assertEquals("[s1, s2]", template.getAlignedMeasurements("`to`.be.prefix").toString());
-
-    template.deleteAlignedPrefix("`to`.be.prefix");
-
-    assertEquals("[GPS]", template.getAllAlignedPrefix().toString());
-    assertEquals(null, template.getDirectNode("prefix"));
-    assertEquals("to", template.getDirectNode("to").getName());
-
-    assertFalse(template.isDirectAligned());
-    try {
-      template.addAlignedMeasurements(
-          new String[] {"speed", "temperature"}, dataTypes, encodings, compressionTypes);
-      fail();
-    } catch (Exception e) {
-      assertEquals(
-          e.getMessage(), " is not a legal path, because path already exists but not aligned");
-    }
-    assertFalse(template.isDirectAligned());
-
-    try {
-      template.deleteMeasurements("a.single");
-      fail();
-    } catch (PathNotExistException e) {
-      assertEquals("Path [a.single] does not exist", e.getMessage());
-    }
-    assertEquals(
-        "[d1.s1, GPS.x, to.be.prefix.s2, GPS.y, to.be.prefix.s1, s2]",
-        template.getAllMeasurementsPaths().toString());
-
-    template.deleteSeriesCascade("`to`");
-
-    assertEquals("[d1.s1, GPS.x, GPS.y, s2]", template.getAllMeasurementsPaths().toString());
-  }
-
   @SuppressWarnings("Duplicates")
   private CreateTemplatePlan getTreeTemplatePlan() {
     /**
@@ -1147,856 +921,146 @@ public abstract class SchemaBasicTest {
   }
 
   @Test
-  @Ignore
-  public void testUnsetSchemaTemplate() throws MetadataException {
-
-    List<List<String>> measurementList = new ArrayList<>();
-    measurementList.add(Collections.singletonList("s1"));
-    measurementList.add(Collections.singletonList("s2"));
-    measurementList.add(Collections.singletonList("s3"));
-
-    List<List<TSDataType>> dataTypeList = new ArrayList<>();
-    dataTypeList.add(Collections.singletonList(TSDataType.INT64));
-    dataTypeList.add(Collections.singletonList(TSDataType.INT64));
-    dataTypeList.add(Collections.singletonList(TSDataType.INT64));
-
-    List<List<TSEncoding>> encodingList = new ArrayList<>();
-    encodingList.add(Collections.singletonList(TSEncoding.RLE));
-    encodingList.add(Collections.singletonList(TSEncoding.RLE));
-    encodingList.add(Collections.singletonList(TSEncoding.RLE));
-
-    List<List<CompressionType>> compressionTypes = new ArrayList<>();
-    for (int i = 0; i < 3; i++) {
-      compressionTypes.add(Collections.singletonList(CompressionType.SNAPPY));
-    }
-    List<String> schemaNames = new ArrayList<>();
-    schemaNames.add("s1");
-    schemaNames.add("s2");
-    schemaNames.add("s3");
-
-    CreateTemplatePlan createTemplatePlan =
-        new CreateTemplatePlan(
-            "template1",
-            schemaNames,
-            measurementList,
-            dataTypeList,
-            encodingList,
-            compressionTypes);
-    SetTemplatePlan setTemplatePlan = new SetTemplatePlan("template1", "root.sg.`1`");
-    UnsetTemplatePlan unsetTemplatePlan = new UnsetTemplatePlan("root.sg.`1`", "template1");
+  public void testShowTimeseries() {
     LocalSchemaProcessor schemaProcessor = IoTDB.schemaProcessor;
-    schemaProcessor.createSchemaTemplate(createTemplatePlan);
-
-    // path does not exist test
     try {
-      schemaProcessor.unsetSchemaTemplate(unsetTemplatePlan);
-      fail("No exception thrown.");
-    } catch (Exception e) {
-      assertEquals("Path [root.sg.`1`] does not exist", e.getMessage());
-    }
+      schemaProcessor.createTimeseries(
+          new PartialPath("root.laptop.d1.s0"),
+          TSDataType.valueOf("INT32"),
+          TSEncoding.valueOf("RLE"),
+          compressionType,
+          Collections.emptyMap());
 
-    schemaProcessor.setSchemaTemplate(setTemplatePlan);
+      // show timeseries root.laptop.d1.s0
+      ShowTimeSeriesPlan showTimeSeriesPlan =
+          new ShowTimeSeriesPlan(
+              new PartialPath("root.laptop.d1.s0"), false, null, null, 0, 0, false);
+      List<ShowTimeSeriesResult> result =
+          schemaProcessor.showTimeseries(showTimeSeriesPlan, EnvironmentUtils.TEST_QUERY_CONTEXT);
+      assertEquals(1, result.size());
+      assertEquals("root.laptop.d1.s0", result.get(0).getName());
+    } catch (MetadataException e) {
+      e.printStackTrace();
+      fail(e.getMessage());
+    }
+  }
 
-    // template unset test
-    schemaProcessor.unsetSchemaTemplate(unsetTemplatePlan);
-    schemaProcessor.setSchemaTemplate(setTemplatePlan);
+  @Test
+  public void testTotalSeriesNumber() throws Exception {
+    LocalSchemaProcessor schemaProcessor = IoTDB.schemaProcessor;
 
-    // no template on path test
-    schemaProcessor.unsetSchemaTemplate(unsetTemplatePlan);
     try {
-      schemaProcessor.unsetSchemaTemplate(unsetTemplatePlan);
-      fail("No exception thrown.");
-    } catch (Exception e) {
-      assertEquals("NO template on root.sg.`1`", e.getMessage());
+      schemaProcessor.setStorageGroup(new PartialPath("root.laptop"));
+      schemaProcessor.createTimeseries(
+          new PartialPath("root.laptop.d0"),
+          TSDataType.INT32,
+          TSEncoding.PLAIN,
+          CompressionType.GZIP,
+          null);
+      schemaProcessor.createTimeseries(
+          new PartialPath("root.laptop.d1.s1"),
+          TSDataType.INT32,
+          TSEncoding.PLAIN,
+          CompressionType.GZIP,
+          null);
+      schemaProcessor.createTimeseries(
+          new PartialPath("root.laptop.d1.s2.t1"),
+          TSDataType.INT32,
+          TSEncoding.PLAIN,
+          CompressionType.GZIP,
+          null);
+      schemaProcessor.createTimeseries(
+          new PartialPath("root.laptop.d1.s3"),
+          TSDataType.INT32,
+          TSEncoding.PLAIN,
+          CompressionType.GZIP,
+          null);
+      schemaProcessor.createTimeseries(
+          new PartialPath("root.laptop.d2.s1"),
+          TSDataType.INT32,
+          TSEncoding.PLAIN,
+          CompressionType.GZIP,
+          null);
+      schemaProcessor.createTimeseries(
+          new PartialPath("root.laptop.d2.s2"),
+          TSDataType.INT32,
+          TSEncoding.PLAIN,
+          CompressionType.GZIP,
+          null);
+
+      assertEquals(6, schemaProcessor.getTotalSeriesNumber());
+      EnvironmentUtils.restartDaemon();
+      assertEquals(6, schemaProcessor.getTotalSeriesNumber());
+      schemaProcessor.deleteTimeseries(new PartialPath("root.laptop.d2.s1"));
+      assertEquals(5, schemaProcessor.getTotalSeriesNumber());
+      schemaProcessor.deleteStorageGroups(
+          Collections.singletonList(new PartialPath("root.laptop")));
+      assertEquals(0, schemaProcessor.getTotalSeriesNumber());
+    } catch (MetadataException e) {
+      e.printStackTrace();
+      fail(e.getMessage());
     }
   }
 
   @Test
-  @Ignore
-  public void testTemplateAndTimeSeriesCompatibility() throws MetadataException {
-    CreateTemplatePlan plan = getCreateTemplatePlan();
+  public void testStorageGroupNameWithHyphen() throws IllegalPathException {
     LocalSchemaProcessor schemaProcessor = IoTDB.schemaProcessor;
-    schemaProcessor.createSchemaTemplate(plan);
-    schemaProcessor.createSchemaTemplate(getTreeTemplatePlan());
-
-    // set device template
-    SetTemplatePlan setTemplatePlan = new SetTemplatePlan("template1", "root.sg1.d1");
-
-    schemaProcessor.setSchemaTemplate(setTemplatePlan);
-    schemaProcessor.setSchemaTemplate(new SetTemplatePlan("treeTemplate", "root.tree.sg0"));
+    assertTrue(schemaProcessor.isPathExist(new PartialPath("root")));
 
-    CreateTimeSeriesPlan createTimeSeriesPlan =
-        new CreateTimeSeriesPlan(
-            new PartialPath("root.sg1.d1.s20"),
-            TSDataType.INT32,
-            TSEncoding.PLAIN,
-            CompressionType.GZIP,
-            null,
-            null,
-            null,
-            null);
+    assertFalse(schemaProcessor.isPathExist(new PartialPath("root.group_with_hyphen")));
 
-    schemaProcessor.createTimeseries(createTimeSeriesPlan);
+    try {
+      schemaProcessor.setStorageGroup(new PartialPath("root.group_with_hyphen"));
+    } catch (MetadataException e) {
+      e.printStackTrace();
+      fail(e.getMessage());
+    }
 
-    CreateTimeSeriesPlan createTimeSeriesPlan2 =
-        new CreateTimeSeriesPlan(
-            new PartialPath("root.sg1.d1.s11"),
-            TSDataType.INT32,
-            TSEncoding.PLAIN,
-            CompressionType.GZIP,
-            null,
-            null,
-            null,
-            null);
+    assertTrue(schemaProcessor.isPathExist(new PartialPath("root.group_with_hyphen")));
+  }
 
+  @Test
+  public void testCreateTimeseriesAndInsertWithAlignedData() {
+    LocalSchemaProcessor schemaProcessor = IoTDB.schemaProcessor;
     try {
-      schemaProcessor.createTimeseries(createTimeSeriesPlan2);
-      fail();
+      schemaProcessor.setStorageGroup(new PartialPath("root.laptop"));
+      schemaProcessor.createTimeseries(
+          new PartialPath("root.laptop.d1.aligned_device.s1"),
+          TSDataType.valueOf("INT32"),
+          TSEncoding.valueOf("RLE"),
+          compressionType,
+          Collections.emptyMap());
+      schemaProcessor.createTimeseries(
+          new PartialPath("root.laptop.d1.aligned_device.s2"),
+          TSDataType.valueOf("INT64"),
+          TSEncoding.valueOf("RLE"),
+          compressionType,
+          Collections.emptyMap());
     } catch (Exception e) {
-      assertEquals("Path [root.sg1.d1.s11] already exists in [template1]", e.getMessage());
+      fail();
     }
 
-    CreateTimeSeriesPlan createTimeSeriesPlan3 =
-        new CreateTimeSeriesPlan(
-            new PartialPath("root.tree.sg0.GPS.s9"),
-            TSDataType.INT32,
-            TSEncoding.PLAIN,
-            CompressionType.GZIP,
-            null,
-            null,
-            null,
-            null);
-
     try {
-      schemaProcessor.createTimeseries(createTimeSeriesPlan3);
+      schemaProcessor.createAlignedTimeSeries(
+          new PartialPath("root.laptop.d1.aligned_device"),
+          Arrays.asList("s3", "s4", "s5"),
+          Arrays.asList(
+              TSDataType.valueOf("FLOAT"),
+              TSDataType.valueOf("INT64"),
+              TSDataType.valueOf("INT32")),
+          Arrays.asList(
+              TSEncoding.valueOf("RLE"), TSEncoding.valueOf("RLE"), TSEncoding.valueOf("RLE")),
+          Arrays.asList(compressionType, compressionType, compressionType));
       fail();
     } catch (Exception e) {
-      assertEquals(
-          "Path [root.tree.sg0.GPS] overlaps with [treeTemplate] on [GPS]", e.getMessage());
+      Assert.assertEquals(
+          "Timeseries under this entity is not aligned, please use createTimeseries or change entity. (Path: root.laptop.d1.aligned_device)",
+          e.getMessage());
     }
-
-    CreateTimeSeriesPlan createTimeSeriesPlan4 =
-        new CreateTimeSeriesPlan(
-            new PartialPath("root.tree.sg0.s3"),
-            TSDataType.INT32,
-            TSEncoding.PLAIN,
-            CompressionType.GZIP,
-            null,
-            null,
-            null,
-            null);
-
-    schemaProcessor.createTimeseries(createTimeSeriesPlan4);
   }
 
   @Test
-  public void testTemplateAndNodePathCompatibility() throws MetadataException {
-    LocalSchemaProcessor schemaProcessor = IoTDB.schemaProcessor;
-    CreateTemplatePlan plan = getCreateTemplatePlan();
-    schemaProcessor.createSchemaTemplate(plan);
-    schemaProcessor.createSchemaTemplate(getTreeTemplatePlan());
-
-    // set device template
-    SetTemplatePlan setTemplatePlan = new SetTemplatePlan("template1", "root.sg1.d1");
-
-    SetTemplatePlan setSchemaTemplatePlan2 = new SetTemplatePlan("treeTemplate", "root.tree.sg0");
-
-    CreateTimeSeriesPlan createTimeSeriesPlan =
-        new CreateTimeSeriesPlan(
-            new PartialPath("root.sg1.d1.s11"),
-            TSDataType.INT32,
-            TSEncoding.PLAIN,
-            CompressionType.GZIP,
-            null,
-            null,
-            null,
-            null);
-
-    schemaProcessor.createTimeseries(createTimeSeriesPlan);
-
-    schemaProcessor.createTimeseries(
-        new CreateTimeSeriesPlan(
-            new PartialPath("root.tree.sg0.s1"),
-            TSDataType.INT32,
-            TSEncoding.PLAIN,
-            CompressionType.GZIP,
-            null,
-            null,
-            null,
-            null));
-
-    schemaProcessor.createTimeseries(
-        new CreateTimeSeriesPlan(
-            new PartialPath("root.tree.sg1.dn.sn"),
-            TSDataType.INT32,
-            TSEncoding.PLAIN,
-            CompressionType.GZIP,
-            null,
-            null,
-            null,
-            null));
-
-    schemaProcessor.createTimeseries(
-        new CreateTimeSeriesPlan(
-            new PartialPath("root.tree.sg2.dn.sn"),
-            TSDataType.INT32,
-            TSEncoding.PLAIN,
-            CompressionType.GZIP,
-            null,
-            null,
-            null,
-            null));
-
-    schemaProcessor.createTimeseries(
-        new CreateTimeSeriesPlan(
-            new PartialPath("root.tree.sg3.dn.sn"),
-            TSDataType.INT32,
-            TSEncoding.PLAIN,
-            CompressionType.GZIP,
-            null,
-            null,
-            null,
-            null));
-
-    try {
-      SetTemplatePlan planErr = new SetTemplatePlan("treeTemplate", "root.tree.*");
-      fail();
-    } catch (IllegalPathException e) {
-      assertEquals(
-          "root.tree.* is not a legal path, because template cannot be set on a path with wildcard.",
-          e.getMessage());
-    }
-
-    SetTemplatePlan planEx1 = new SetTemplatePlan("treeTemplate", "root.tree.sg1");
-    SetTemplatePlan planEx2 = new SetTemplatePlan("treeTemplate", "root.tree.sg2");
-    SetTemplatePlan planEx3 = new SetTemplatePlan("treeTemplate", "root.tree.sg3");
-    schemaProcessor.setSchemaTemplate(planEx1);
-    schemaProcessor.setSchemaTemplate(planEx2);
-    schemaProcessor.setSchemaTemplate(planEx3);
-
-    try {
-      schemaProcessor.unsetSchemaTemplate(new UnsetTemplatePlan("root.tree.*", "treeTemplate"));
-      fail();
-    } catch (IllegalPathException e) {
-      assertEquals(
-          "root.tree.* is not a legal path, because template cannot be unset on a path with wildcard.",
-          e.getMessage());
-    }
-
-    schemaProcessor.setSchemaTemplate(setSchemaTemplatePlan2);
-    schemaProcessor.unsetSchemaTemplate(new UnsetTemplatePlan("root.tree.sg0", "treeTemplate"));
-    try {
-      schemaProcessor.setSchemaTemplate(setTemplatePlan);
-      fail();
-    } catch (MetadataException e) {
-      assertEquals(
-          "Node name s11 in template has conflict with node's child root.sg1.d1.s11",
-          e.getMessage());
-    }
-
-    schemaProcessor.createTimeseries(
-        new CreateTimeSeriesPlan(
-            new PartialPath("root.tree.sg0.GPS.speed"),
-            TSDataType.INT32,
-            TSEncoding.PLAIN,
-            CompressionType.GZIP,
-            null,
-            null,
-            null,
-            null));
-
-    try {
-      schemaProcessor.setSchemaTemplate(setSchemaTemplatePlan2);
-      fail();
-    } catch (MetadataException e) {
-      assertEquals(
-          "Node name GPS in template has conflict with node's child root.tree.sg0.GPS",
-          e.getMessage());
-    }
-
-    schemaProcessor.deleteTimeseries(new PartialPath("root.sg1.d1.s11"));
-  }
-
-  @Test
-  @Ignore
-  public void testSetDeviceTemplate() throws MetadataException {
-    List<List<String>> measurementList = new ArrayList<>();
-    measurementList.add(Collections.singletonList("s11"));
-    List<String> measurements = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      measurements.add("s" + i);
-    }
-    measurementList.add(measurements);
-
-    List<List<TSDataType>> dataTypeList = new ArrayList<>();
-    dataTypeList.add(Collections.singletonList(TSDataType.INT64));
-    List<TSDataType> dataTypes = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      dataTypes.add(TSDataType.INT64);
-    }
-    dataTypeList.add(dataTypes);
-
-    List<List<TSEncoding>> encodingList = new ArrayList<>();
-    encodingList.add(Collections.singletonList(TSEncoding.RLE));
-    List<TSEncoding> encodings = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      encodings.add(TSEncoding.RLE);
-    }
-    encodingList.add(encodings);
-
-    List<List<CompressionType>> compressionTypes = new ArrayList<>();
-    List<CompressionType> compressionTypeList = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      compressionTypeList.add(CompressionType.SNAPPY);
-    }
-    compressionTypes.add(Collections.singletonList(CompressionType.SNAPPY));
-    compressionTypes.add(compressionTypeList);
-
-    List<String> schemaNames = new ArrayList<>();
-    schemaNames.add("s11");
-    schemaNames.add("test_aligned_device");
-
-    CreateTemplatePlan plan1 =
-        new CreateTemplatePlan(
-            "template1",
-            schemaNames,
-            measurementList,
-            dataTypeList,
-            encodingList,
-            compressionTypes);
-
-    measurementList.add(Collections.singletonList("s12"));
-    schemaNames.add("s12");
-    dataTypeList.add(Collections.singletonList(TSDataType.INT64));
-    encodingList.add(Collections.singletonList(TSEncoding.RLE));
-    compressionTypes.add(Collections.singletonList(CompressionType.SNAPPY));
-
-    CreateTemplatePlan plan2 =
-        new CreateTemplatePlan(
-            "template2",
-            new ArrayList<>(schemaNames),
-            new ArrayList<>(measurementList),
-            new ArrayList<>(dataTypeList),
-            new ArrayList<>(encodingList),
-            new ArrayList<>(compressionTypes));
-
-    measurementList.get(1).add("s13");
-    dataTypeList.get(1).add(TSDataType.INT64);
-    encodingList.get(1).add(TSEncoding.RLE);
-    compressionTypes.get(1).add(CompressionType.SNAPPY);
-
-    SetTemplatePlan setPlan1 = new SetTemplatePlan("template1", "root.sg1");
-    SetTemplatePlan setPlan2 = new SetTemplatePlan("template2", "root.sg2.d1");
-
-    SetTemplatePlan setPlan3 = new SetTemplatePlan("template1", "root.sg1.d1");
-    SetTemplatePlan setPlan4 = new SetTemplatePlan("template2", "root.sg2");
-
-    SetTemplatePlan setPlan5 = new SetTemplatePlan("template2", "root.sg1.d1");
-
-    LocalSchemaProcessor schemaProcessor = IoTDB.schemaProcessor;
-
-    schemaProcessor.createSchemaTemplate(plan1);
-    schemaProcessor.createSchemaTemplate(plan2);
-
-    schemaProcessor.setStorageGroup(new PartialPath("root.sg1"));
-    schemaProcessor.setStorageGroup(new PartialPath("root.sg2"));
-    schemaProcessor.setStorageGroup(new PartialPath("root.sg3"));
-
-    try {
-      schemaProcessor.setSchemaTemplate(setPlan1);
-      schemaProcessor.setSchemaTemplate(setPlan2);
-    } catch (MetadataException e) {
-      fail();
-    }
-
-    try {
-      schemaProcessor.setSchemaTemplate(setPlan3);
-      fail();
-    } catch (MetadataException e) {
-      assertEquals("Template already exists on root.sg1", e.getMessage());
-    }
-
-    try {
-      schemaProcessor.setSchemaTemplate(setPlan4);
-      fail();
-    } catch (MetadataException e) {
-      assertEquals("Template already exists on root.sg2.d1", e.getMessage());
-    }
-
-    try {
-      schemaProcessor.setSchemaTemplate(setPlan5);
-      fail();
-    } catch (MetadataException e) {
-      assertEquals("Template already exists on root.sg1", e.getMessage());
-    }
-  }
-
-  @Test
-  public void testShowTimeseries() {
-    LocalSchemaProcessor schemaProcessor = IoTDB.schemaProcessor;
-    try {
-      schemaProcessor.createTimeseries(
-          new PartialPath("root.laptop.d1.s0"),
-          TSDataType.valueOf("INT32"),
-          TSEncoding.valueOf("RLE"),
-          compressionType,
-          Collections.emptyMap());
-
-      // show timeseries root.laptop.d1.s0
-      ShowTimeSeriesPlan showTimeSeriesPlan =
-          new ShowTimeSeriesPlan(
-              new PartialPath("root.laptop.d1.s0"), false, null, null, 0, 0, false);
-      List<ShowTimeSeriesResult> result =
-          schemaProcessor.showTimeseries(showTimeSeriesPlan, EnvironmentUtils.TEST_QUERY_CONTEXT);
-      assertEquals(1, result.size());
-      assertEquals("root.laptop.d1.s0", result.get(0).getName());
-    } catch (MetadataException e) {
-      e.printStackTrace();
-      fail(e.getMessage());
-    }
-  }
-
-  @Test
-  @Ignore
-  public void testShowTimeseriesWithTemplate() {
-    List<List<String>> measurementList = new ArrayList<>();
-    measurementList.add(Collections.singletonList("s0"));
-    List<String> measurements = new ArrayList<>();
-    for (int i = 1; i <= 3; i++) {
-      measurements.add("vector.s" + i);
-    }
-    measurementList.add(measurements);
-
-    List<List<TSDataType>> dataTypeList = new ArrayList<>();
-    dataTypeList.add(Collections.singletonList(TSDataType.INT32));
-    List<TSDataType> dataTypes = new ArrayList<>();
-    dataTypes.add(TSDataType.INT32);
-    dataTypes.add(TSDataType.FLOAT);
-    dataTypes.add(TSDataType.INT32);
-    dataTypeList.add(dataTypes);
-
-    List<List<TSEncoding>> encodingList = new ArrayList<>();
-    encodingList.add(Collections.singletonList(TSEncoding.RLE));
-    List<TSEncoding> encodings = new ArrayList<>();
-    for (int i = 1; i <= 3; i++) {
-      encodings.add(TSEncoding.RLE);
-    }
-    encodingList.add(encodings);
-
-    List<List<CompressionType>> compressionTypes = new ArrayList<>();
-    compressionTypes.add(Collections.singletonList(CompressionType.SNAPPY));
-    List<CompressionType> compressorList = new ArrayList<>();
-    for (int i = 0; i <= 2; i++) {
-      compressorList.add(compressionType);
-    }
-    compressionTypes.add(compressorList);
-
-    List<String> schemaNames = new ArrayList<>();
-    schemaNames.add("s0");
-    schemaNames.add("vector");
-
-    CreateTemplatePlan plan =
-        new CreateTemplatePlan(
-            "template1",
-            schemaNames,
-            measurementList,
-            dataTypeList,
-            encodingList,
-            compressionTypes);
-    CreateTemplatePlan treePlan = getTreeTemplatePlan();
-    LocalSchemaProcessor schemaProcessor = IoTDB.schemaProcessor;
-    try {
-      schemaProcessor.createSchemaTemplate(plan);
-      schemaProcessor.createSchemaTemplate(treePlan);
-
-      // set device template
-
-      SetTemplatePlan setSchemaTemplatePlan = new SetTemplatePlan("template1", "root.laptop.d1");
-      SetTemplatePlan setSchemaTemplatePlan1 = new SetTemplatePlan("treeTemplate", "root.tree.d0");
-      schemaProcessor.setSchemaTemplate(setSchemaTemplatePlan);
-      schemaProcessor.setSchemaTemplate(setSchemaTemplatePlan1);
-      schemaProcessor.setUsingSchemaTemplate(
-          new ActivateTemplatePlan(new PartialPath("root.laptop.d1")));
-      schemaProcessor.setUsingSchemaTemplate(
-          new ActivateTemplatePlan(new PartialPath("root.tree.d0")));
-
-      // show timeseries root.tree.d0
-      ShowTimeSeriesPlan showTreeTSPlan =
-          new ShowTimeSeriesPlan(
-              new PartialPath("root.tree.d0.**"), false, null, null, 0, 0, false);
-      List<ShowTimeSeriesResult> treeShowResult =
-          schemaProcessor.showTimeseries(showTreeTSPlan, EnvironmentUtils.TEST_QUERY_CONTEXT);
-      assertEquals(4, treeShowResult.size());
-      Set<String> checkSet = new HashSet<>();
-      checkSet.add("root.tree.d0.d1.s1");
-      checkSet.add("root.tree.d0.s2");
-      checkSet.add("root.tree.d0.GPS.x");
-      checkSet.add("root.tree.d0.GPS.y");
-      for (ShowTimeSeriesResult res : treeShowResult) {
-        checkSet.remove(res.getName());
-      }
-      assertTrue(checkSet.isEmpty());
-
-      // show timeseries root.laptop.d1.s0
-      ShowTimeSeriesPlan showTimeSeriesPlan =
-          new ShowTimeSeriesPlan(
-              new PartialPath("root.laptop.d1.s0"), false, null, null, 0, 0, false);
-      List<ShowTimeSeriesResult> result =
-          schemaProcessor.showTimeseries(showTimeSeriesPlan, EnvironmentUtils.TEST_QUERY_CONTEXT);
-      assertEquals(1, result.size());
-      assertEquals("root.laptop.d1.s0", result.get(0).getName());
-
-      // show timeseries root.laptop.d1.(s1,s2,s3)
-      showTimeSeriesPlan =
-          new ShowTimeSeriesPlan(
-              new PartialPath("root.laptop.d1.vector.s1"), false, null, null, 0, 0, false);
-      result =
-          schemaProcessor.showTimeseries(showTimeSeriesPlan, EnvironmentUtils.TEST_QUERY_CONTEXT);
-
-      assertEquals(1, result.size());
-      assertEquals("root.laptop.d1.vector.s1", result.get(0).getName());
-
-      // show timeseries root.laptop.d1.(s1,s2,s3)
-      showTimeSeriesPlan =
-          new ShowTimeSeriesPlan(new PartialPath("root.laptop.**"), false, null, null, 0, 0, false);
-      result =
-          schemaProcessor.showTimeseries(showTimeSeriesPlan, EnvironmentUtils.TEST_QUERY_CONTEXT);
-      assertEquals(4, result.size());
-      Set<String> set = new HashSet<>();
-      for (int i = 1; i < result.size(); i++) {
-        set.add("root.laptop.d1.vector.s" + i);
-      }
-      set.add("root.laptop.d1.s0");
-
-      for (int i = 0; i < result.size(); i++) {
-        set.remove(result.get(i).getName());
-      }
-
-      assertTrue(set.isEmpty());
-    } catch (MetadataException e) {
-      e.printStackTrace();
-      fail(e.getMessage());
-    }
-  }
-
-  @Test
-  @Ignore
-  public void minimumTestForWildcardInTemplate() throws MetadataException {
-    LocalSchemaProcessor schemaProcessor = IoTDB.schemaProcessor;
-    CreateTemplatePlan treePlan = getTreeTemplatePlan();
-    schemaProcessor.createSchemaTemplate(treePlan);
-
-    // set device template
-    SetTemplatePlan setSchemaTemplatePlan1 = new SetTemplatePlan("treeTemplate", "root.tree.d0");
-    schemaProcessor.setSchemaTemplate(setSchemaTemplatePlan1);
-    schemaProcessor.setUsingSchemaTemplate(
-        new ActivateTemplatePlan(new PartialPath("root.tree.d0")));
-
-    ShowTimeSeriesPlan showTimeSeriesPlan =
-        new ShowTimeSeriesPlan(new PartialPath("root.tree.**.s1"), false, null, null, 0, 0, false);
-    List<ShowTimeSeriesResult> result =
-        schemaProcessor.showTimeseries(showTimeSeriesPlan, EnvironmentUtils.TEST_QUERY_CONTEXT);
-    assertEquals(1, result.size());
-  }
-
-  @Test
-  @Ignore
-  public void testCountTimeseriesWithTemplate() throws IOException {
-    List<List<String>> measurementList = new ArrayList<>();
-    measurementList.add(Collections.singletonList("s0"));
-    measurementList.add(Collections.singletonList("s1"));
-
-    List<List<TSDataType>> dataTypeList = new ArrayList<>();
-    dataTypeList.add(Collections.singletonList(TSDataType.INT32));
-    dataTypeList.add(Collections.singletonList(TSDataType.FLOAT));
-
-    List<List<TSEncoding>> encodingList = new ArrayList<>();
-    encodingList.add(Collections.singletonList(TSEncoding.RLE));
-    encodingList.add(Collections.singletonList(TSEncoding.RLE));
-
-    List<List<CompressionType>> compressionTypes = new ArrayList<>();
-    for (int i = 0; i < 2; i++) {
-      compressionTypes.add(Collections.singletonList(compressionType));
-    }
-
-    List<String> schemaNames = new ArrayList<>();
-    schemaNames.add("s0");
-    schemaNames.add("s1");
-
-    CreateTemplatePlan plan =
-        new CreateTemplatePlan(
-            "template1",
-            schemaNames,
-            measurementList,
-            dataTypeList,
-            encodingList,
-            compressionTypes);
-    LocalSchemaProcessor schemaProcessor = IoTDB.schemaProcessor;
-    try {
-      schemaProcessor.createSchemaTemplate(plan);
-      schemaProcessor.createSchemaTemplate(getTreeTemplatePlan());
-
-      // set device template
-      SetTemplatePlan setSchemaTemplatePlan = new SetTemplatePlan("template1", "root.laptop.d1");
-      schemaProcessor.setSchemaTemplate(setSchemaTemplatePlan);
-      schemaProcessor.setSchemaTemplate(new SetTemplatePlan("treeTemplate", "root.tree.d0"));
-      schemaProcessor.setUsingSchemaTemplate(
-          new ActivateTemplatePlan(new PartialPath("root.laptop.d1")));
-
-      schemaProcessor.createTimeseries(
-          new PartialPath("root.computer.d1.s2"),
-          TSDataType.INT32,
-          TSEncoding.PLAIN,
-          CompressionType.GZIP,
-          null);
-
-      SetTemplatePlan setTemplatePlan = new SetTemplatePlan("template1", "root.computer");
-      schemaProcessor.setSchemaTemplate(setTemplatePlan);
-      schemaProcessor.setUsingSchemaTemplate(
-          new ActivateTemplatePlan(new PartialPath("root.computer.d1")));
-      schemaProcessor.setUsingSchemaTemplate(
-          new ActivateTemplatePlan(new PartialPath("root.tree.d0")));
-      schemaProcessor.setUsingSchemaTemplate(
-          new ActivateTemplatePlan(new PartialPath("root.tree.d0.v0")));
-      schemaProcessor.setUsingSchemaTemplate(
-          new ActivateTemplatePlan(new PartialPath("root.tree.d0.v1")));
-
-      Assert.assertEquals(
-          2, schemaProcessor.getAllTimeseriesCount(new PartialPath("root.laptop.d1.**")));
-      Assert.assertEquals(
-          1, schemaProcessor.getAllTimeseriesCount(new PartialPath("root.laptop.d1.s1")));
-      Assert.assertEquals(
-          1, schemaProcessor.getAllTimeseriesCount(new PartialPath("root.computer.d1.s1")));
-      Assert.assertEquals(
-          1, schemaProcessor.getAllTimeseriesCount(new PartialPath("root.computer.d1.s2")));
-      Assert.assertEquals(
-          3, schemaProcessor.getAllTimeseriesCount(new PartialPath("root.computer.d1.**")));
-      Assert.assertEquals(
-          3, schemaProcessor.getAllTimeseriesCount(new PartialPath("root.computer.**")));
-      Assert.assertEquals(
-          12, schemaProcessor.getAllTimeseriesCount(new PartialPath("root.tree.**")));
-      Assert.assertEquals(17, schemaProcessor.getAllTimeseriesCount(new PartialPath("root.**")));
-
-    } catch (MetadataException e) {
-      e.printStackTrace();
-      fail(e.getMessage());
-    }
-  }
-
-  @Test
-  @Ignore
-  public void testCountDeviceWithTemplate() {
-    List<List<String>> measurementList = new ArrayList<>();
-    measurementList.add(Collections.singletonList("s0"));
-    measurementList.add(Collections.singletonList("s1"));
-
-    List<List<TSDataType>> dataTypeList = new ArrayList<>();
-    dataTypeList.add(Collections.singletonList(TSDataType.INT32));
-    dataTypeList.add(Collections.singletonList(TSDataType.FLOAT));
-
-    List<List<TSEncoding>> encodingList = new ArrayList<>();
-    encodingList.add(Collections.singletonList(TSEncoding.RLE));
-    encodingList.add(Collections.singletonList(TSEncoding.RLE));
-
-    List<List<CompressionType>> compressionTypes = new ArrayList<>();
-    for (int i = 0; i < 2; i++) {
-      compressionTypes.add(Collections.singletonList(compressionType));
-    }
-
-    List<String> schemaNames = new ArrayList<>();
-    schemaNames.add("s0");
-    schemaNames.add("s1");
-
-    CreateTemplatePlan plan =
-        new CreateTemplatePlan(
-            "template1",
-            schemaNames,
-            measurementList,
-            dataTypeList,
-            encodingList,
-            compressionTypes);
-    LocalSchemaProcessor schemaProcessor = IoTDB.schemaProcessor;
-
-    try {
-      schemaProcessor.createSchemaTemplate(plan);
-      schemaProcessor.createSchemaTemplate(getTreeTemplatePlan());
-      // set device template
-      SetTemplatePlan setSchemaTemplatePlan = new SetTemplatePlan("template1", "root.laptop.d1");
-      schemaProcessor.setSchemaTemplate(setSchemaTemplatePlan);
-      schemaProcessor.setSchemaTemplate(new SetTemplatePlan("treeTemplate", "root.tree.d0"));
-      schemaProcessor.setUsingSchemaTemplate(
-          new ActivateTemplatePlan(new PartialPath("root.laptop.d1")));
-      schemaProcessor.setUsingSchemaTemplate(
-          new ActivateTemplatePlan(new PartialPath("root.tree.d0")));
-
-      try {
-        schemaProcessor.setUsingSchemaTemplate(
-            new ActivateTemplatePlan(new PartialPath("root.non.existed.path")));
-        fail();
-      } catch (MetadataException e) {
-        assertEquals("Path [root.non.existed.path] has not been set any template.", e.getMessage());
-      }
-
-      schemaProcessor.createTimeseries(
-          new PartialPath("root.laptop.d2.s1"),
-          TSDataType.INT32,
-          TSEncoding.PLAIN,
-          CompressionType.GZIP,
-          null);
-
-      Assert.assertEquals(1, schemaProcessor.getDevicesNum(new PartialPath("root.laptop.d1")));
-      Assert.assertEquals(1, schemaProcessor.getDevicesNum(new PartialPath("root.laptop.d2")));
-      Assert.assertEquals(2, schemaProcessor.getDevicesNum(new PartialPath("root.laptop.*")));
-      Assert.assertEquals(2, schemaProcessor.getDevicesNum(new PartialPath("root.laptop.**")));
-      // ignore the device in tree template for new cluster single level template dev
-      Assert.assertEquals(1, schemaProcessor.getDevicesNum(new PartialPath("root.tree.**")));
-      Assert.assertEquals(3, schemaProcessor.getDevicesNum(new PartialPath("root.**")));
-
-      schemaProcessor.createTimeseries(
-          new PartialPath("root.laptop.d1.a.s3"),
-          TSDataType.INT32,
-          TSEncoding.PLAIN,
-          CompressionType.GZIP,
-          null);
-
-      schemaProcessor.createTimeseries(
-          new PartialPath("root.laptop.d2.a.s3"),
-          TSDataType.INT32,
-          TSEncoding.PLAIN,
-          CompressionType.GZIP,
-          null);
-
-      Assert.assertEquals(4, schemaProcessor.getDevicesNum(new PartialPath("root.laptop.**")));
-
-      schemaProcessor.deleteTimeseries(new PartialPath("root.laptop.d2.s1"));
-      Assert.assertEquals(3, schemaProcessor.getDevicesNum(new PartialPath("root.laptop.**")));
-      schemaProcessor.deleteTimeseries(new PartialPath("root.laptop.d2.a.s3"));
-      Assert.assertEquals(2, schemaProcessor.getDevicesNum(new PartialPath("root.laptop.**")));
-      schemaProcessor.deleteTimeseries(new PartialPath("root.laptop.d1.a.s3"));
-      Assert.assertEquals(1, schemaProcessor.getDevicesNum(new PartialPath("root.laptop.**")));
-
-    } catch (MetadataException e) {
-      e.printStackTrace();
-      fail(e.getMessage());
-    }
-  }
-
-  @Test
-  public void testTotalSeriesNumber() throws Exception {
-    LocalSchemaProcessor schemaProcessor = IoTDB.schemaProcessor;
-
-    try {
-      schemaProcessor.setStorageGroup(new PartialPath("root.laptop"));
-      schemaProcessor.createTimeseries(
-          new PartialPath("root.laptop.d0"),
-          TSDataType.INT32,
-          TSEncoding.PLAIN,
-          CompressionType.GZIP,
-          null);
-      schemaProcessor.createTimeseries(
-          new PartialPath("root.laptop.d1.s1"),
-          TSDataType.INT32,
-          TSEncoding.PLAIN,
-          CompressionType.GZIP,
-          null);
-      schemaProcessor.createTimeseries(
-          new PartialPath("root.laptop.d1.s2.t1"),
-          TSDataType.INT32,
-          TSEncoding.PLAIN,
-          CompressionType.GZIP,
-          null);
-      schemaProcessor.createTimeseries(
-          new PartialPath("root.laptop.d1.s3"),
-          TSDataType.INT32,
-          TSEncoding.PLAIN,
-          CompressionType.GZIP,
-          null);
-      schemaProcessor.createTimeseries(
-          new PartialPath("root.laptop.d2.s1"),
-          TSDataType.INT32,
-          TSEncoding.PLAIN,
-          CompressionType.GZIP,
-          null);
-      schemaProcessor.createTimeseries(
-          new PartialPath("root.laptop.d2.s2"),
-          TSDataType.INT32,
-          TSEncoding.PLAIN,
-          CompressionType.GZIP,
-          null);
-
-      assertEquals(6, schemaProcessor.getTotalSeriesNumber());
-      EnvironmentUtils.restartDaemon();
-      assertEquals(6, schemaProcessor.getTotalSeriesNumber());
-      schemaProcessor.deleteTimeseries(new PartialPath("root.laptop.d2.s1"));
-      assertEquals(5, schemaProcessor.getTotalSeriesNumber());
-      schemaProcessor.deleteStorageGroups(
-          Collections.singletonList(new PartialPath("root.laptop")));
-      assertEquals(0, schemaProcessor.getTotalSeriesNumber());
-    } catch (MetadataException e) {
-      e.printStackTrace();
-      fail(e.getMessage());
-    }
-  }
-
-  @Test
-  public void testStorageGroupNameWithHyphen() throws IllegalPathException {
-    LocalSchemaProcessor schemaProcessor = IoTDB.schemaProcessor;
-    assertTrue(schemaProcessor.isPathExist(new PartialPath("root")));
-
-    assertFalse(schemaProcessor.isPathExist(new PartialPath("root.group_with_hyphen")));
-
-    try {
-      schemaProcessor.setStorageGroup(new PartialPath("root.group_with_hyphen"));
-    } catch (MetadataException e) {
-      e.printStackTrace();
-      fail(e.getMessage());
-    }
-
-    assertTrue(schemaProcessor.isPathExist(new PartialPath("root.group_with_hyphen")));
-  }
-
-  @Test
-  public void testCreateTimeseriesAndInsertWithAlignedData() {
-    LocalSchemaProcessor schemaProcessor = IoTDB.schemaProcessor;
-    try {
-      schemaProcessor.setStorageGroup(new PartialPath("root.laptop"));
-      schemaProcessor.createTimeseries(
-          new PartialPath("root.laptop.d1.aligned_device.s1"),
-          TSDataType.valueOf("INT32"),
-          TSEncoding.valueOf("RLE"),
-          compressionType,
-          Collections.emptyMap());
-      schemaProcessor.createTimeseries(
-          new PartialPath("root.laptop.d1.aligned_device.s2"),
-          TSDataType.valueOf("INT64"),
-          TSEncoding.valueOf("RLE"),
-          compressionType,
-          Collections.emptyMap());
-    } catch (Exception e) {
-      fail();
-    }
-
-    try {
-      schemaProcessor.createAlignedTimeSeries(
-          new PartialPath("root.laptop.d1.aligned_device"),
-          Arrays.asList("s3", "s4", "s5"),
-          Arrays.asList(
-              TSDataType.valueOf("FLOAT"),
-              TSDataType.valueOf("INT64"),
-              TSDataType.valueOf("INT32")),
-          Arrays.asList(
-              TSEncoding.valueOf("RLE"), TSEncoding.valueOf("RLE"), TSEncoding.valueOf("RLE")),
-          Arrays.asList(compressionType, compressionType, compressionType));
-      fail();
-    } catch (Exception e) {
-      Assert.assertEquals(
-          "Timeseries under this entity is not aligned, please use createTimeseries or change entity. (Path: root.laptop.d1.aligned_device)",
-          e.getMessage());
-    }
-  }
-
-  @Test
-  public void testCreateAlignedTimeseriesWithIllegalNames() throws Exception {
+  public void testCreateAlignedTimeseriesWithIllegalNames() throws Exception {
     LocalSchemaProcessor schemaProcessor = IoTDB.schemaProcessor;
     schemaProcessor.setStorageGroup(new PartialPath("root.laptop"));
     PartialPath deviceId = new PartialPath("root.laptop.d1");
@@ -2151,20 +1215,6 @@ public abstract class SchemaBasicTest {
     }
   }
 
-  @Test
-  public void testTemplateSchemaNameCheckWhileCreate() {
-    LocalSchemaProcessor schemaProcessor = IoTDB.schemaProcessor;
-    String[] illegalSchemaNames = {"a+b", "time", "timestamp", "TIME", "TIMESTAMP"};
-    for (String schemaName : illegalSchemaNames) {
-      CreateTemplatePlan plan = getCreateTemplatePlan(schemaName);
-      try {
-        schemaProcessor.createSchemaTemplate(plan);
-      } catch (MetadataException e) {
-        Assert.assertEquals(String.format("%s is an illegal name.", schemaName), e.getMessage());
-      }
-    }
-  }
-
   private CreateTemplatePlan getCreateTemplatePlan(String schemaName) {
     List<List<String>> measurementList = new ArrayList<>();
     measurementList.add(Collections.singletonList("s0"));
@@ -2185,36 +1235,6 @@ public abstract class SchemaBasicTest {
         "template1", schemaNames, measurementList, dataTypeList, encodingList, compressionTypes);
   }
 
-  @Test
-  @Ignore
-  public void testTimeseriesDeletionWithEntityUsingTemplate() throws MetadataException {
-    LocalSchemaProcessor schemaProcessor = IoTDB.schemaProcessor;
-    schemaProcessor.setStorageGroup(new PartialPath("root.sg"));
-
-    CreateTemplatePlan plan = getCreateTemplatePlan("s1");
-    schemaProcessor.createSchemaTemplate(plan);
-    SetTemplatePlan setPlan = new SetTemplatePlan("template1", "root.sg.d1");
-    schemaProcessor.setSchemaTemplate(setPlan);
-    schemaProcessor.createTimeseries(
-        new PartialPath("root.sg.d1.s2"),
-        TSDataType.valueOf("INT32"),
-        TSEncoding.valueOf("RLE"),
-        compressionType,
-        Collections.emptyMap());
-    schemaProcessor.setUsingSchemaTemplate(new ActivateTemplatePlan(new PartialPath("root.sg.d1")));
-    schemaProcessor.deleteTimeseries(new PartialPath("root.sg.d1.s2"));
-    assertTrue(schemaProcessor.isPathExist(new PartialPath("root.sg.d1")));
-
-    schemaProcessor.createTimeseries(
-        new PartialPath("root.sg.d2.s2"),
-        TSDataType.valueOf("INT32"),
-        TSEncoding.valueOf("RLE"),
-        compressionType,
-        Collections.emptyMap());
-    schemaProcessor.deleteTimeseries(new PartialPath("root.sg.d2.s2"));
-    assertFalse(schemaProcessor.isPathExist(new PartialPath("root.sg.d2")));
-  }
-
   @Test
   public void testTagIndexRecovery() throws Exception {
     LocalSchemaProcessor schemaProcessor = IoTDB.schemaProcessor;
@@ -2273,39 +1293,6 @@ public abstract class SchemaBasicTest {
     assertEquals("newValue", resultTag.get("description"));
   }
 
-  @Test
-  public void testTagCreationViaMLogPlanDuringMetadataSync() throws Exception {
-    LocalSchemaProcessor schemaProcessor = IoTDB.schemaProcessor;
-
-    PartialPath path = new PartialPath("root.sg.d.s");
-    Map<String, String> tags = new HashMap<>();
-    tags.put("type", "test");
-    CreateTimeSeriesPlan plan =
-        new CreateTimeSeriesPlan(
-            path,
-            TSDataType.valueOf("INT32"),
-            TSEncoding.valueOf("RLE"),
-            compressionType,
-            null,
-            tags,
-            null,
-            null);
-    // mock that the plan has already been executed on sender and receiver will redo this plan
-    plan.setTagOffset(10);
-
-    schemaProcessor.operation(plan);
-
-    ShowTimeSeriesPlan showTimeSeriesPlan =
-        new ShowTimeSeriesPlan(new PartialPath("root.sg.d.s"), true, "type", "test", 0, 0, false);
-    List<ShowTimeSeriesResult> results =
-        schemaProcessor.showTimeseries(showTimeSeriesPlan, new QueryContext());
-    assertEquals(1, results.size());
-    Map<String, String> resultTag = results.get(0).getTag();
-    assertEquals("test", resultTag.get("type"));
-
-    assertEquals(0, schemaProcessor.getMeasurementMNode(path).getOffset());
-  }
-
   @Test
   public void testCountNodesWithLevel() throws Exception {
     LocalSchemaProcessor schemaProcessor = IoTDB.schemaProcessor;
diff --git a/server/src/test/java/org/apache/iotdb/db/metadata/TemplateTest.java b/server/src/test/java/org/apache/iotdb/db/metadata/TemplateTest.java
index 41d8aff180..1288da7395 100644
--- a/server/src/test/java/org/apache/iotdb/db/metadata/TemplateTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/metadata/TemplateTest.java
@@ -18,26 +18,12 @@
  */
 package org.apache.iotdb.db.metadata;
 
-import org.apache.iotdb.commons.exception.MetadataException;
-import org.apache.iotdb.commons.path.MeasurementPath;
-import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.db.exception.metadata.PathNotExistException;
-import org.apache.iotdb.db.metadata.mnode.IMNode;
-import org.apache.iotdb.db.metadata.mnode.IMeasurementMNode;
-import org.apache.iotdb.db.metadata.template.Template;
 import org.apache.iotdb.db.qp.physical.PhysicalPlan;
-import org.apache.iotdb.db.qp.physical.sys.ActivateTemplatePlan;
 import org.apache.iotdb.db.qp.physical.sys.CreateTemplatePlan;
-import org.apache.iotdb.db.qp.physical.sys.DropTemplatePlan;
-import org.apache.iotdb.db.qp.physical.sys.SetTemplatePlan;
-import org.apache.iotdb.db.qp.physical.sys.UnsetTemplatePlan;
-import org.apache.iotdb.db.service.IoTDB;
 import org.apache.iotdb.db.utils.EnvironmentUtils;
 import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
-import org.apache.iotdb.tsfile.write.schema.IMeasurementSchema;
-import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
 
 import org.junit.After;
 import org.junit.Before;
@@ -50,14 +36,9 @@ import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
-import java.util.HashSet;
 import java.util.List;
-import java.util.Set;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 public class TemplateTest {
   @Before
@@ -70,101 +51,6 @@ public class TemplateTest {
     EnvironmentUtils.cleanEnv();
   }
 
-  @Test
-  public void testTemplate() throws MetadataException {
-    CreateTemplatePlan plan = getCreateTemplatePlan();
-
-    LocalSchemaProcessor schemaProcessor = IoTDB.schemaProcessor;
-    schemaProcessor.createSchemaTemplate(plan);
-
-    // set device template
-    SetTemplatePlan setTemplatePlan = new SetTemplatePlan("template1", "root.sg1.d1");
-
-    schemaProcessor.setSchemaTemplate(setTemplatePlan);
-
-    schemaProcessor.setUsingSchemaTemplate(
-        new ActivateTemplatePlan(new PartialPath("root.sg1.d1")));
-    IMNode node = schemaProcessor.getDeviceNode(new PartialPath("root.sg1.d1"));
-
-    MeasurementSchema s11 =
-        new MeasurementSchema("s11", TSDataType.INT64, TSEncoding.RLE, CompressionType.SNAPPY);
-    assertNotNull(node.getSchemaTemplate());
-
-    Set<IMeasurementSchema> allSchema =
-        new HashSet<>(node.getSchemaTemplate().getSchemaMap().values());
-    schemaProcessor.getAllMeasurementByDevicePath(new PartialPath("root.sg1.d1")).stream()
-        .map(MeasurementPath::getMeasurementSchema)
-        .forEach(allSchema::remove);
-
-    assertTrue(allSchema.isEmpty());
-
-    IMeasurementMNode mNode =
-        schemaProcessor.getMeasurementMNode(new PartialPath("root.sg1.d1.s11"));
-    IMeasurementMNode mNode2 =
-        schemaProcessor.getMeasurementMNode(new PartialPath("root.sg1.d1.vector.s2"));
-    assertNotNull(mNode);
-    assertEquals(mNode.getSchema(), s11);
-    assertNotNull(mNode2);
-    assertEquals(
-        mNode2.getSchema(),
-        schemaProcessor.getTemplate("template1").getSchemaMap().get("vector.s2"));
-
-    try {
-      schemaProcessor.getMeasurementMNode(new PartialPath("root.sg1.d1.s100"));
-      fail();
-    } catch (PathNotExistException e) {
-      assertEquals("Path [root.sg1.d1.s100] does not exist", e.getMessage());
-    }
-  }
-
-  @Test
-  public void testTemplateInnerTree() {
-    CreateTemplatePlan plan = getTreeTemplatePlan();
-    Template template;
-    LocalSchemaProcessor schemaProcessor = IoTDB.schemaProcessor;
-
-    try {
-      schemaProcessor.createSchemaTemplate(plan);
-      template = schemaProcessor.getTemplate("treeTemplate");
-      assertEquals(4, template.getMeasurementsCount());
-      assertEquals("d1", template.getPathNodeInTemplate("d1").getName());
-      assertEquals(null, template.getPathNodeInTemplate("notExists"));
-      assertEquals("[GPS]", template.getAllAlignedPrefix().toString());
-
-      String[] alignedMeasurements = {"to.be.prefix.s1", "to.be.prefix.s2"};
-      TSDataType[] dataTypes = {TSDataType.INT32, TSDataType.INT32};
-      TSEncoding[] encodings = {TSEncoding.RLE, TSEncoding.RLE};
-      CompressionType[] compressionTypes = {CompressionType.SNAPPY, CompressionType.SNAPPY};
-      template.addAlignedMeasurements(alignedMeasurements, dataTypes, encodings, compressionTypes);
-
-      assertEquals("[to.be.prefix, GPS]", template.getAllAlignedPrefix().toString());
-      assertEquals("[s1, s2]", template.getAlignedMeasurements("to.be.prefix").toString());
-
-      template.deleteAlignedPrefix("to.be.prefix");
-
-      assertEquals("[GPS]", template.getAllAlignedPrefix().toString());
-      assertEquals(null, template.getDirectNode("prefix"));
-      assertEquals("to", template.getDirectNode("to").getName());
-
-      try {
-        template.deleteMeasurements("a.single");
-        fail();
-      } catch (MetadataException e) {
-        assertEquals("Path [a.single] does not exist", e.getMessage());
-      }
-      assertEquals(
-          "[d1.s1, GPS.x, to.be.prefix.s2, GPS.y, to.be.prefix.s1, s2]",
-          template.getAllMeasurementsPaths().toString());
-
-      template.deleteSeriesCascade("to");
-
-      assertEquals("[d1.s1, GPS.x, GPS.y, s2]", template.getAllMeasurementsPaths().toString());
-
-    } catch (MetadataException e) {
-      e.printStackTrace();
-    }
-  }
-
   @Test
   public void testCreateSchemaTemplateSerialization() throws IOException {
     CreateTemplatePlan plan = getTreeTemplatePlan();
@@ -186,11 +72,11 @@ public class TemplateTest {
   }
 
   private CreateTemplatePlan getTreeTemplatePlan() {
-    /**
-     * Construct a template like: create schema template treeTemplate ( (d1.s1 INT32 GORILLA
-     * SNAPPY), (s2 INT32 GORILLA SNAPPY), (GPS.x FLOAT RLE SNAPPY), (GPS.y FLOAT RLE SNAPPY), )with
-     * aligned (GPS)
-     */
+    /*
+     Construct a template like: create schema template treeTemplate ( (d1.s1 INT32 GORILLA
+     SNAPPY), (s2 INT32 GORILLA SNAPPY), (GPS.x FLOAT RLE SNAPPY), (GPS.y FLOAT RLE SNAPPY), )with
+     aligned (GPS)
+    */
     List<List<String>> measurementList = new ArrayList<>();
     measurementList.add(Collections.singletonList("d1.s1"));
     measurementList.add(Collections.singletonList("s2"));
@@ -291,187 +177,4 @@ public class TemplateTest {
     return new CreateTemplatePlan(
         "templateDA", schemaNames, measurementList, dataTypeList, encodingList, compressionTypes);
   }
-
-  /**
-   * Test for show templates, including all templates, paths set or using designated template
-   *
-   * @throws MetadataException
-   */
-  //  @Test
-  //  public void testShowTemplates() throws MetadataException, QueryProcessException {
-  //    LocalSchemaProcessor schemaProcessor = IoTDB.schemaProcessor;
-  //    assertEquals(0, schemaProcessor.getAllTemplates().size());
-  //    CreateTemplatePlan plan1 = getTreeTemplatePlan();
-  //    CreateTemplatePlan plan2 = getCreateTemplatePlan();
-  //    schemaProcessor.createSchemaTemplate(plan1);
-  //    schemaProcessor.createSchemaTemplate(plan2);
-  //
-  //    assertEquals("[template1, treeTemplate]", schemaProcessor.getAllTemplates().toString());
-  //
-  //    for (int i = 0; i < 3; i++) {
-  //      SetTemplatePlan setTemplatePlan =
-  //          new SetTemplatePlan("template1", String.format("root.sg%d.d%d", i, i + 1));
-  //      schemaProcessor.setSchemaTemplate(setTemplatePlan);
-  //    }
-  //
-  //    assertEquals(
-  //        new HashSet<>(Arrays.asList("root.sg1.d2", "root.sg0.d1", "root.sg2.d3")),
-  //        schemaProcessor.getPathsSetTemplate("*"));
-  //    assertEquals(
-  //        new HashSet<>(Arrays.asList()), schemaProcessor.getPathsSetTemplate("treeTemplate"));
-  //
-  //    for (int i = 0; i < 3; i++) {
-  //      SetTemplatePlan setTemplatePlan =
-  //          new SetTemplatePlan("treeTemplate", String.format("root.tsg%d.d%d", i + 9, i + 10));
-  //      schemaProcessor.setSchemaTemplate(setTemplatePlan);
-  //    }
-  //
-  //    assertEquals(
-  //        new HashSet<>(Arrays.asList("root.tsg10.d11", "root.tsg11.d12", "root.tsg9.d10")),
-  //        schemaProcessor.getPathsSetTemplate("treeTemplate"));
-  //    assertEquals(
-  //        new HashSet<>(
-  //            Arrays.asList(
-  //                "root.tsg10.d11",
-  //                "root.tsg11.d12",
-  //                "root.tsg9.d10",
-  //                "root.sg1.d2",
-  //                "root.sg0.d1",
-  //                "root.sg2.d3")),
-  //        schemaProcessor.getPathsSetTemplate("*"));
-  //
-  //    PlanExecutor exe1 = new PlanExecutor();
-  //    exe1.insert(getInsertRowPlan("root.sg0.d1", "s11"));
-  //    exe1.insert(getInsertRowPlan("root.sg1.d2", "s11"));
-  //    exe1.insert(getInsertRowPlan("root.tsg10.d11.d1", "s1"));
-  //
-  //    assertEquals(
-  //        new HashSet<>(Arrays.asList("root.tsg10.d11", "root.sg1.d2", "root.sg0.d1")),
-  //        schemaProcessor.getPathsUsingTemplate("*"));
-  //
-  //    try {
-  //      schemaProcessor.createSchemaTemplate(plan1);
-  //      fail();
-  //    } catch (MetadataException e) {
-  //      assertEquals("Duplicated template name: treeTemplate", e.getMessage());
-  //    }
-  //
-  //    try {
-  //      schemaProcessor.dropSchemaTemplate(new DropTemplatePlan("treeTemplate"));
-  //      fail();
-  //    } catch (MetadataException e) {
-  //      assertEquals(
-  //          "Template [treeTemplate] has been set on MTree, cannot be dropped now.",
-  // e.getMessage());
-  //    }
-  //  }
-
-  @Test
-  public void testShowAllSchemas() throws MetadataException {
-    LocalSchemaProcessor schemaProcessor = IoTDB.schemaProcessor;
-    CreateTemplatePlan plan1 = getTreeTemplatePlan();
-    CreateTemplatePlan plan2 = getCreateTemplatePlan();
-    schemaProcessor.createSchemaTemplate(plan1);
-    schemaProcessor.createSchemaTemplate(plan2);
-    assertEquals(4, schemaProcessor.getSchemasInTemplate("treeTemplate", "").size());
-    assertEquals(2, schemaProcessor.getSchemasInTemplate("treeTemplate", "GPS").size());
-    assertEquals(11, schemaProcessor.getSchemasInTemplate("template1", "").size());
-    assertEquals(10, schemaProcessor.getSchemasInTemplate("template1", "vector").size());
-  }
-
-  @Test
-  public void testDropTemplate() throws MetadataException {
-    LocalSchemaProcessor schemaProcessor = IoTDB.schemaProcessor;
-    CreateTemplatePlan plan1 = getTreeTemplatePlan();
-    CreateTemplatePlan plan2 = getCreateTemplatePlan();
-    schemaProcessor.createSchemaTemplate(plan1);
-    schemaProcessor.createSchemaTemplate(plan2);
-
-    assertEquals("[template1, treeTemplate]", schemaProcessor.getAllTemplates().toString());
-
-    try {
-      schemaProcessor.createSchemaTemplate(plan2);
-      fail();
-    } catch (MetadataException e) {
-      assertEquals("Duplicated template name: template1", e.getMessage());
-    }
-
-    SetTemplatePlan setTemplatePlan = new SetTemplatePlan("template1", "root.sg.d0");
-    schemaProcessor.setSchemaTemplate(setTemplatePlan);
-
-    try {
-      schemaProcessor.dropSchemaTemplate(new DropTemplatePlan("template1"));
-      fail();
-    } catch (MetadataException e) {
-      assertEquals(
-          "Template [template1] has been set on MTree, cannot be dropped now.", e.getMessage());
-    }
-
-    UnsetTemplatePlan unsetPlan = new UnsetTemplatePlan("root.sg.d0", "template1");
-    schemaProcessor.unsetSchemaTemplate(unsetPlan);
-
-    schemaProcessor.dropSchemaTemplate(new DropTemplatePlan("template1"));
-    assertEquals("[treeTemplate]", schemaProcessor.getAllTemplates().toString());
-    schemaProcessor.createSchemaTemplate(plan2);
-    assertEquals("[template1, treeTemplate]", schemaProcessor.getAllTemplates().toString());
-    schemaProcessor.dropSchemaTemplate(new DropTemplatePlan("template1"));
-    schemaProcessor.dropSchemaTemplate(new DropTemplatePlan("treeTemplate"));
-  }
-
-  @Test
-  public void testDropTemplateWithStorageGroupDeleted() throws MetadataException {
-    LocalSchemaProcessor schemaProcessor = IoTDB.schemaProcessor;
-    schemaProcessor.createSchemaTemplate(getTreeTemplatePlan());
-    schemaProcessor.setSchemaTemplate(new SetTemplatePlan("treeTemplate", "root.sg1.d1"));
-    try {
-      schemaProcessor.dropSchemaTemplate(new DropTemplatePlan("treeTemplate"));
-      fail();
-    } catch (MetadataException e) {
-      assertEquals(
-          "Template [treeTemplate] has been set on MTree, cannot be dropped now.", e.getMessage());
-    }
-
-    schemaProcessor.deleteStorageGroups(Arrays.asList(new PartialPath("root.sg1")));
-    schemaProcessor.dropSchemaTemplate(new DropTemplatePlan("treeTemplate"));
-    assertEquals(0, schemaProcessor.getAllTemplates().size());
-  }
-
-  @Test
-  public void testTemplateAlignment() throws MetadataException {
-    LocalSchemaProcessor schemaProcessor = IoTDB.schemaProcessor;
-    schemaProcessor.createTimeseries(
-        new PartialPath("root.laptop.d0"),
-        TSDataType.INT32,
-        TSEncoding.PLAIN,
-        CompressionType.GZIP,
-        null);
-    schemaProcessor.createTimeseries(
-        new PartialPath("root.laptop.d1.s1"),
-        TSDataType.INT32,
-        TSEncoding.PLAIN,
-        CompressionType.GZIP,
-        null);
-    schemaProcessor.createTimeseries(
-        new PartialPath("root.laptop.d1.s2"),
-        TSDataType.INT32,
-        TSEncoding.PLAIN,
-        CompressionType.GZIP,
-        null);
-    schemaProcessor.createTimeseries(
-        new PartialPath("root.laptop.d1.ss.t1"),
-        TSDataType.INT32,
-        TSEncoding.PLAIN,
-        CompressionType.GZIP,
-        null);
-
-    schemaProcessor.createSchemaTemplate(getDirectAlignedTemplate());
-    try {
-      schemaProcessor.setSchemaTemplate(new SetTemplatePlan("templateDA", "root.laptop.d1"));
-      fail();
-    } catch (Exception e) {
-      assertEquals(
-          "Template[templateDA] and mounted node[root.laptop.d1.vs0] has different alignment.",
-          e.getMessage());
-    }
-  }
 }
diff --git a/server/src/test/java/org/apache/iotdb/db/metadata/plan/SchemaRegionPlanCompatibilityTest.java b/server/src/test/java/org/apache/iotdb/db/metadata/plan/SchemaRegionPlanCompatibilityTest.java
index 45472776e7..9082cd7b10 100644
--- a/server/src/test/java/org/apache/iotdb/db/metadata/plan/SchemaRegionPlanCompatibilityTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/metadata/plan/SchemaRegionPlanCompatibilityTest.java
@@ -24,7 +24,6 @@ import org.apache.iotdb.commons.path.PartialPath;
 import org.apache.iotdb.db.metadata.plan.schemaregion.SchemaRegionPlanType;
 import org.apache.iotdb.db.metadata.plan.schemaregion.impl.SchemaRegionPlanDeserializer;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IActivateTemplateInClusterPlan;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.IActivateTemplatePlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IAutoCreateDeviceMNodePlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IChangeAliasPlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IChangeTagOffsetPlan;
@@ -33,11 +32,8 @@ import org.apache.iotdb.db.metadata.plan.schemaregion.write.ICreateTimeSeriesPla
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IDeleteTimeSeriesPlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IPreDeleteTimeSeriesPlan;
 import org.apache.iotdb.db.metadata.plan.schemaregion.write.IRollbackPreDeleteTimeSeriesPlan;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.ISetTemplatePlan;
-import org.apache.iotdb.db.metadata.plan.schemaregion.write.IUnsetTemplatePlan;
 import org.apache.iotdb.db.qp.physical.PhysicalPlan;
 import org.apache.iotdb.db.qp.physical.sys.ActivateTemplateInClusterPlan;
-import org.apache.iotdb.db.qp.physical.sys.ActivateTemplatePlan;
 import org.apache.iotdb.db.qp.physical.sys.AutoCreateDeviceMNodePlan;
 import org.apache.iotdb.db.qp.physical.sys.ChangeAliasPlan;
 import org.apache.iotdb.db.qp.physical.sys.ChangeTagOffsetPlan;
@@ -46,8 +42,6 @@ import org.apache.iotdb.db.qp.physical.sys.CreateTimeSeriesPlan;
 import org.apache.iotdb.db.qp.physical.sys.DeleteTimeSeriesPlan;
 import org.apache.iotdb.db.qp.physical.sys.PreDeleteTimeSeriesPlan;
 import org.apache.iotdb.db.qp.physical.sys.RollbackPreDeleteTimeSeriesPlan;
-import org.apache.iotdb.db.qp.physical.sys.SetTemplatePlan;
-import org.apache.iotdb.db.qp.physical.sys.UnsetTemplatePlan;
 import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
@@ -91,11 +85,8 @@ public class SchemaRegionPlanCompatibilityTest {
           "DELETE_TIMESERIES",
           "CHANGE_TAG_OFFSET",
           "CHANGE_ALIAS",
-          "SET_TEMPLATE",
-          "ACTIVATE_TEMPLATE",
           "AUTO_CREATE_DEVICE_MNODE",
           "CREATE_ALIGNED_TIMESERIES",
-          "UNSET_TEMPLATE",
           "ACTIVATE_TEMPLATE_IN_CLUSTER",
           "PRE_DELETE_TIMESERIES_IN_CLUSTER",
           "ROLLBACK_PRE_DELETE_TIMESERIES"
@@ -128,20 +119,6 @@ public class SchemaRegionPlanCompatibilityTest {
     Assert.assertEquals(position, getCurrentBufferPosition());
   }
 
-  @Test
-  public void testActivateTemplatePlanSerializationCompatibility() throws IllegalPathException {
-    ActivateTemplatePlan oldPlan = new ActivateTemplatePlan();
-    oldPlan.setPrefixPath(new PartialPath("root.sg.d"));
-
-    int position = serializeToBuffer(oldPlan);
-
-    IActivateTemplatePlan newPlan = deserializeFromBuffer();
-
-    Assert.assertEquals(oldPlan.getPrefixPath(), newPlan.getPrefixPath());
-
-    Assert.assertEquals(position, getCurrentBufferPosition());
-  }
-
   @Test
   public void testAutoCreateDeviceMNodePlanSerializationCompatibility()
       throws IllegalPathException {
@@ -299,36 +276,4 @@ public class SchemaRegionPlanCompatibilityTest {
 
     Assert.assertEquals(position, getCurrentBufferPosition());
   }
-
-  @Test
-  public void testSetTemplatePlanSerializationCompatibility() {
-    SetTemplatePlan oldPlan = new SetTemplatePlan();
-    oldPlan.setPrefixPath("root.sg");
-    oldPlan.setTemplateName("template");
-
-    int position = serializeToBuffer(oldPlan);
-
-    ISetTemplatePlan newPlan = deserializeFromBuffer();
-
-    Assert.assertEquals(oldPlan.getPrefixPath(), newPlan.getPrefixPath());
-    Assert.assertEquals(oldPlan.getTemplateName(), newPlan.getTemplateName());
-
-    Assert.assertEquals(position, getCurrentBufferPosition());
-  }
-
-  @Test
-  public void testUnsetTemplatePlanSerializationCompatibility() {
-    UnsetTemplatePlan oldPlan = new UnsetTemplatePlan();
-    oldPlan.setPrefixPath("root.sg");
-    oldPlan.setTemplateName("template");
-
-    int position = serializeToBuffer(oldPlan);
-
-    IUnsetTemplatePlan newPlan = deserializeFromBuffer();
-
-    Assert.assertEquals(oldPlan.getPrefixPath(), newPlan.getPrefixPath());
-    Assert.assertEquals(oldPlan.getTemplateName(), newPlan.getTemplateName());
-
-    Assert.assertEquals(position, getCurrentBufferPosition());
-  }
 }
diff --git a/server/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaRegionBasicTest.java b/server/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaRegionBasicTest.java
index 2fd109b35a..9135a5fdb9 100644
--- a/server/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaRegionBasicTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaRegionBasicTest.java
@@ -440,12 +440,7 @@ public abstract class SchemaRegionBasicTest {
     Assert.assertEquals("root.sg.wf02.wt01.temperature", schemas.get(0).getFullPath());
   }
 
-  /**
-   * Test {@link ISchemaRegion#activateSchemaTemplate}.
-   *
-   * <p>Check using {@link ISchemaRegion#getPathsUsingTemplate} and {@link
-   * ISchemaRegion#countPathsUsingTemplate}
-   */
+  /** Test {@link ISchemaRegion#activateSchemaTemplate}. */
   @Test
   public void testActivateSchemaTemplate() throws Exception {
     PartialPath storageGroup = new PartialPath("root.sg");
@@ -514,9 +509,6 @@ public abstract class SchemaRegionBasicTest {
    * Test {@link ISchemaRegion#constructSchemaBlackListWithTemplate}, {@link
    * ISchemaRegion#rollbackSchemaBlackListWithTemplate} and {@link
    * ISchemaRegion#deactivateTemplateInBlackList}
-   *
-   * <p>Check using {@link ISchemaRegion#getPathsUsingTemplate} and {@link
-   * ISchemaRegion#countPathsUsingTemplate}
    */
   @Test
   public void testDeactivateTemplate() throws Exception {
diff --git a/server/src/test/java/org/apache/iotdb/db/metadata/upgrade/MetadataUpgradeTest.java b/server/src/test/java/org/apache/iotdb/db/metadata/upgrade/MetadataUpgradeTest.java
deleted file mode 100644
index 921e51b446..0000000000
--- a/server/src/test/java/org/apache/iotdb/db/metadata/upgrade/MetadataUpgradeTest.java
+++ /dev/null
@@ -1,318 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.db.metadata.upgrade;
-
-import org.apache.iotdb.commons.exception.IllegalPathException;
-import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.db.conf.IoTDBConfig;
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.metadata.LocalSchemaProcessor;
-import org.apache.iotdb.db.metadata.MetadataConstant;
-import org.apache.iotdb.db.metadata.logfile.MLogWriter;
-import org.apache.iotdb.db.metadata.mnode.EntityMNode;
-import org.apache.iotdb.db.metadata.mnode.IEntityMNode;
-import org.apache.iotdb.db.metadata.mnode.IMNode;
-import org.apache.iotdb.db.metadata.mnode.IMeasurementMNode;
-import org.apache.iotdb.db.metadata.mnode.IStorageGroupMNode;
-import org.apache.iotdb.db.metadata.mnode.InternalMNode;
-import org.apache.iotdb.db.metadata.mnode.MeasurementMNode;
-import org.apache.iotdb.db.metadata.mnode.StorageGroupMNode;
-import org.apache.iotdb.db.metadata.tag.TagLogFile;
-import org.apache.iotdb.db.qp.physical.sys.AutoCreateDeviceMNodePlan;
-import org.apache.iotdb.db.qp.physical.sys.CreateAlignedTimeSeriesPlan;
-import org.apache.iotdb.db.qp.physical.sys.CreateTemplatePlan;
-import org.apache.iotdb.db.qp.physical.sys.CreateTimeSeriesPlan;
-import org.apache.iotdb.db.qp.physical.sys.SetTemplatePlan;
-import org.apache.iotdb.db.qp.physical.sys.ShowTimeSeriesPlan;
-import org.apache.iotdb.db.qp.physical.sys.UnsetTemplatePlan;
-import org.apache.iotdb.db.query.dataset.ShowTimeSeriesResult;
-import org.apache.iotdb.db.service.IoTDB;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.apache.iotdb.db.utils.writelog.LogWriter;
-import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
-import org.apache.iotdb.tsfile.write.schema.IMeasurementSchema;
-import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
-
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.io.File;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-import static org.apache.iotdb.commons.conf.IoTDBConstant.PATH_ROOT;
-
-public class MetadataUpgradeTest {
-
-  private IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
-  private String schemaDirPath = config.getSchemaDir();
-
-  @Before
-  public void setUp() {
-    EnvironmentUtils.envSetUp();
-  }
-
-  @After
-  public void tearDown() throws Exception {
-    EnvironmentUtils.cleanEnv();
-  }
-
-  @Test
-  public void testMetadataUpgrade() throws Exception {
-    prepareSnapshot();
-    prepareTagFile();
-    prepareMLog();
-
-    IoTDB.configManager.clear();
-    MetadataUpgrader.upgrade();
-    IoTDB.configManager.init();
-
-    LocalSchemaProcessor schemaProcessor = IoTDB.schemaProcessor;
-    Assert.assertEquals(8, schemaProcessor.getStorageGroupNum(new PartialPath("root.**"), false));
-    Assert.assertEquals(10, schemaProcessor.getAllTimeseriesCount(new PartialPath("root.**")));
-
-    ShowTimeSeriesPlan showTimeSeriesPlan =
-        new ShowTimeSeriesPlan(
-            new PartialPath("root.**"), false, "t-k-0", "t-k-0-v-0", 0, 0, false);
-    List<ShowTimeSeriesResult> resultList =
-        schemaProcessor.showTimeseries(showTimeSeriesPlan, null);
-    Assert.assertEquals(1, resultList.size());
-    ShowTimeSeriesResult result = resultList.get(0);
-    Assert.assertEquals("root.test.sg1.d1.s1", result.getName());
-
-    showTimeSeriesPlan =
-        new ShowTimeSeriesPlan(
-            new PartialPath("root.**"), false, "t-k-1", "t-k-1-v-1", 0, 0, false);
-    resultList = schemaProcessor.showTimeseries(showTimeSeriesPlan, null);
-    resultList =
-        resultList.stream()
-            .sorted(Comparator.comparing(ShowTimeSeriesResult::getName))
-            .collect(Collectors.toList());
-    Assert.assertEquals(2, resultList.size());
-    result = resultList.get(0);
-    Assert.assertEquals("root.test.sg1.d2.s1", result.getName());
-    result = resultList.get(1);
-    Assert.assertEquals("root.test.sg2.d1.s1", result.getName());
-
-    Assert.assertEquals(4, schemaProcessor.getPathsSetTemplate("template").size());
-    Assert.assertEquals(0, schemaProcessor.getPathsSetTemplate("unsetTemplate").size());
-
-    Assert.assertEquals(
-        "root.test.sg3.d3",
-        new ArrayList<>(schemaProcessor.getPathsUsingTemplate("template")).get(0));
-    Assert.assertTrue(
-        new File(schemaDirPath + File.separator + MetadataConstant.METADATA_LOG + ".bak").exists());
-    Assert.assertTrue(
-        new File(schemaDirPath + File.separator + MetadataConstant.TAG_LOG + ".bak").exists());
-    Assert.assertTrue(
-        new File(
-                schemaDirPath
-                    + File.separator
-                    + MetadataConstant.MTREE_SNAPSHOT_OLD_VERSION
-                    + ".bak")
-            .exists());
-  }
-
-  private void prepareMLog() throws Exception {
-    try (MLogWriter logWriter =
-        new MLogWriter(schemaDirPath + File.separator + MetadataConstant.METADATA_LOG)) {
-
-      CreateTimeSeriesPlan createTimeSeriesPlan =
-          new CreateTimeSeriesPlan(
-              new PartialPath("root.test.sg1.d2.s1"),
-              TSDataType.INT32,
-              TSEncoding.PLAIN,
-              CompressionType.GZIP,
-              null,
-              null,
-              null,
-              null);
-      createTimeSeriesPlan.setTagOffset(-1);
-      logWriter.createTimeseries(createTimeSeriesPlan);
-
-      createTimeSeriesPlan =
-          new CreateTimeSeriesPlan(
-              new PartialPath("root.test.sg1.d2.s2"),
-              TSDataType.INT32,
-              TSEncoding.PLAIN,
-              CompressionType.GZIP,
-              null,
-              null,
-              null,
-              null);
-      logWriter.createTimeseries(createTimeSeriesPlan);
-
-      logWriter.setStorageGroup(new PartialPath("root.test.sg2"));
-
-      Map<String, String> tags = new HashMap<>();
-      tags.put("t-k-1", "t-k-1-v-1");
-      createTimeSeriesPlan =
-          new CreateTimeSeriesPlan(
-              new PartialPath("root.test.sg2.d1.s1"),
-              TSDataType.INT32,
-              TSEncoding.PLAIN,
-              CompressionType.GZIP,
-              null,
-              tags,
-              null,
-              null);
-      createTimeSeriesPlan.setTagOffset(config.getTagAttributeTotalSize());
-      logWriter.createTimeseries(createTimeSeriesPlan);
-
-      logWriter.changeOffset(
-          new PartialPath("root.test.sg1.d2.s1"), 2L * config.getTagAttributeTotalSize());
-
-      CreateTemplatePlan createTemplatePlan = getCreateTemplatePlan("template", "s3");
-      logWriter.createSchemaTemplate(createTemplatePlan);
-      SetTemplatePlan setTemplatePlan = new SetTemplatePlan("template", "root.test");
-      logWriter.setSchemaTemplate(setTemplatePlan);
-
-      logWriter.setStorageGroup(new PartialPath("root.test.sg3"));
-      logWriter.autoCreateDeviceMNode(
-          new AutoCreateDeviceMNodePlan(new PartialPath("root.test.sg3.d3")));
-      logWriter.setUsingSchemaTemplate(new PartialPath("root.test.sg3.d3"));
-
-      logWriter.setStorageGroup(new PartialPath("root.unsetTemplate1.sg1"));
-      logWriter.createSchemaTemplate(getCreateTemplatePlan("unsetTemplate", "s1"));
-      logWriter.setSchemaTemplate(new SetTemplatePlan("unsetTemplate", "root.unsetTemplate1"));
-      logWriter.setStorageGroup(new PartialPath("root.unsetTemplate1.sg2"));
-      logWriter.unsetSchemaTemplate(new UnsetTemplatePlan("root.unsetTemplate1", "unsetTemplate"));
-
-      logWriter.setStorageGroup(new PartialPath("root.unsetTemplate2.sg1"));
-      logWriter.setSchemaTemplate(new SetTemplatePlan("unsetTemplate", "root.unsetTemplate2"));
-      logWriter.unsetSchemaTemplate(new UnsetTemplatePlan("root.unsetTemplate2", "unsetTemplate"));
-
-      logWriter.setStorageGroup(new PartialPath("root.test.sg4"));
-      logWriter.setStorageGroup(new PartialPath("root.unsetTemplate2.sg2"));
-
-      logWriter.force();
-    }
-
-    CreateAlignedTimeSeriesPlan createAlignedTimeSeriesPlan = getCreateAlignedTimeseriesPlan();
-    LogWriter rawLogWriter =
-        new LogWriter(schemaDirPath + File.separator + MetadataConstant.METADATA_LOG, true);
-    try {
-      ByteBuffer byteBuffer = ByteBuffer.allocate(1024 * 1024);
-      createAlignedTimeSeriesPlan.formerSerialize(byteBuffer);
-      rawLogWriter.write(byteBuffer);
-      rawLogWriter.force();
-    } finally {
-      rawLogWriter.close();
-    }
-  }
-
-  private CreateTemplatePlan getCreateTemplatePlan(String templateName, String measurementName) {
-    List<List<String>> measurementList = new ArrayList<>();
-    measurementList.add(Collections.singletonList(measurementName));
-
-    List<List<TSDataType>> dataTypeList = new ArrayList<>();
-    dataTypeList.add(Collections.singletonList(TSDataType.INT64));
-
-    List<List<TSEncoding>> encodingList = new ArrayList<>();
-    encodingList.add(Collections.singletonList(TSEncoding.RLE));
-
-    List<List<CompressionType>> compressionTypes = new ArrayList<>();
-    compressionTypes.add(Collections.singletonList(CompressionType.SNAPPY));
-
-    List<String> schemaNames = new ArrayList<>();
-    schemaNames.add(measurementName);
-
-    return new CreateTemplatePlan(
-        templateName, schemaNames, measurementList, dataTypeList, encodingList, compressionTypes);
-  }
-
-  private CreateAlignedTimeSeriesPlan getCreateAlignedTimeseriesPlan() throws IllegalPathException {
-    PartialPath devicePath = new PartialPath("root.unsetTemplate1.sg1.device0");
-    List<String> measurements = Arrays.asList("s1", "s2", "s3", "s4", "s5");
-    List<TSDataType> tsDataTypes =
-        Arrays.asList(
-            TSDataType.DOUBLE,
-            TSDataType.TEXT,
-            TSDataType.FLOAT,
-            TSDataType.BOOLEAN,
-            TSDataType.INT32);
-    List<TSEncoding> tsEncodings =
-        Arrays.asList(
-            TSEncoding.PLAIN,
-            TSEncoding.PLAIN,
-            TSEncoding.PLAIN,
-            TSEncoding.PLAIN,
-            TSEncoding.PLAIN);
-    List<CompressionType> compressionTypes =
-        Arrays.asList(
-            CompressionType.UNCOMPRESSED,
-            CompressionType.UNCOMPRESSED,
-            CompressionType.UNCOMPRESSED,
-            CompressionType.UNCOMPRESSED,
-            CompressionType.UNCOMPRESSED);
-    return new CreateAlignedTimeSeriesPlan(
-        devicePath, measurements, tsDataTypes, tsEncodings, compressionTypes, null, null, null);
-  }
-
-  private void prepareTagFile() throws Exception {
-    try (TagLogFile tagLogFile = new TagLogFile(schemaDirPath, MetadataConstant.TAG_LOG)) {
-      Map<String, String> tags = new HashMap<>();
-      Map<String, String> attributes = new HashMap<>();
-
-      tags.put("t-k-0", "t-k-0-v-0");
-      tagLogFile.write(tags, attributes);
-
-      tags.clear();
-      tags.put("t-k-1", "t-k-1-v-1");
-      tagLogFile.write(tags, attributes);
-
-      tags.clear();
-      tags.put("t-k-1", "t-k-1-v-1");
-      tagLogFile.write(tags, attributes);
-    }
-  }
-
-  private void prepareSnapshot() throws Exception {
-    IMNode root = new InternalMNode(null, PATH_ROOT);
-    IMNode test = new InternalMNode(root, "test");
-    root.addChild(test);
-    IStorageGroupMNode storageGroupMNode = new StorageGroupMNode(test, "sg1", 10000);
-    test.addChild(storageGroupMNode);
-    IEntityMNode entityMNode = new EntityMNode(storageGroupMNode, "d1");
-    storageGroupMNode.addChild(entityMNode);
-    IMeasurementSchema schema =
-        new MeasurementSchema("s1", TSDataType.INT32, TSEncoding.PLAIN, CompressionType.GZIP, null);
-    IMeasurementMNode measurementMNode =
-        MeasurementMNode.getMeasurementMNode(entityMNode, "s1", schema, "first");
-    measurementMNode.setOffset(0);
-    entityMNode.addChild(measurementMNode);
-    entityMNode.addAlias("first", measurementMNode);
-    try (MLogWriter mLogWriter =
-        new MLogWriter(
-            schemaDirPath + File.separator + MetadataConstant.MTREE_SNAPSHOT_OLD_VERSION)) {
-      root.serializeTo(mLogWriter);
-    }
-  }
-}
diff --git a/server/src/test/java/org/apache/iotdb/db/tools/MLogParserTest.java b/server/src/test/java/org/apache/iotdb/db/tools/MLogParserTest.java
index 730b9ac67c..11ccfcaf43 100644
--- a/server/src/test/java/org/apache/iotdb/db/tools/MLogParserTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/tools/MLogParserTest.java
@@ -21,13 +21,9 @@ package org.apache.iotdb.db.tools;
 
 import org.apache.iotdb.commons.exception.MetadataException;
 import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.db.conf.IoTDBConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.metadata.MetadataConstant;
-import org.apache.iotdb.db.qp.physical.sys.ActivateTemplatePlan;
-import org.apache.iotdb.db.qp.physical.sys.CreateTemplatePlan;
 import org.apache.iotdb.db.qp.physical.sys.CreateTimeSeriesPlan;
-import org.apache.iotdb.db.qp.physical.sys.SetTemplatePlan;
 import org.apache.iotdb.db.service.IoTDB;
 import org.apache.iotdb.db.tools.schema.MLogParser;
 import org.apache.iotdb.db.utils.EnvironmentUtils;
@@ -45,7 +41,6 @@ import java.io.File;
 import java.io.FileReader;
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -59,15 +54,13 @@ public class MLogParserTest {
    * For root.sg0, we prepare 50 CreateTimeseriesPlan.
    * For root.sg1, we prepare 50 CreateTimeseriesPlan, 1 DeleteTimeseriesPlan, 1 ChangeTagOffsetPlan and 1 ChangeAliasPlan.
    * For root.sgcc, we prepare 0 plans on timeseries or device or template.
-   * For root.sg, we prepare 1 SetTemplatePlan, 1 AutoCreateDevicePlan and 1 ActivateTemplatePlan.
+   * For root.sg, we prepare none schema plan.
    *
    * For root.ln.cc, we create it and then delete it, thus there's no mlog of root.ln.cc.
    * There' still 1 CreateTemplatePlan in template_log.bin
    *
    * */
-  private int[] mlogLineNum = new int[] {50, 53, 0, 3};
-
-  private IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
+  private int[] mlogLineNum = new int[] {50, 53, 0, 0};
 
   @Before
   public void setUp() {
@@ -120,41 +113,11 @@ public class MLogParserTest {
 
     try {
       IoTDB.schemaProcessor.setStorageGroup(new PartialPath("root.sg"));
-      IoTDB.schemaProcessor.createSchemaTemplate(genCreateSchemaTemplatePlan());
-      SetTemplatePlan setTemplatePlan = new SetTemplatePlan("template1", "root.sg");
-      IoTDB.schemaProcessor.setSchemaTemplate(setTemplatePlan);
-      IoTDB.schemaProcessor.setUsingSchemaTemplate(
-          new ActivateTemplatePlan(new PartialPath("root.sg.d1")));
     } catch (MetadataException e) {
       e.printStackTrace();
     }
   }
 
-  private CreateTemplatePlan genCreateSchemaTemplatePlan() {
-    List<List<String>> measurementList = new ArrayList<>();
-    measurementList.add(Collections.singletonList("s11"));
-    measurementList.add(Collections.singletonList("s12"));
-
-    List<List<TSDataType>> dataTypeList = new ArrayList<>();
-    dataTypeList.add(Collections.singletonList(TSDataType.INT64));
-    dataTypeList.add(Collections.singletonList(TSDataType.DOUBLE));
-
-    List<List<TSEncoding>> encodingList = new ArrayList<>();
-    encodingList.add(Collections.singletonList(TSEncoding.RLE));
-    encodingList.add(Collections.singletonList(TSEncoding.GORILLA));
-
-    List<List<CompressionType>> compressionTypes = new ArrayList<>();
-    compressionTypes.add(Collections.singletonList(CompressionType.SNAPPY));
-    compressionTypes.add(Collections.singletonList(CompressionType.SNAPPY));
-
-    List<String> schemaNames = new ArrayList<>();
-    schemaNames.add("s11");
-    schemaNames.add("s12");
-
-    return new CreateTemplatePlan(
-        "template1", schemaNames, measurementList, dataTypeList, encodingList, compressionTypes);
-  }
-
   @Test
   public void testMLogParser() throws Exception {
     prepareData();