针对架构设计的最佳做法Best practices for schema design

下面是要遵循的一些最佳做法。Here are several best practices to follow. 它们可以提高管理命令的效率,对服务资源的影响较小。They'll help make your management commands work better, and have a lighter impact on the service resources.

操作Action 用途Use 不要使用Don't use 注释Notes
创建多个表Create multiple tables 使用单个 .create tables 命令Use a single .create tables command 不要发出多个 .create table 命令Don't issue many .create table commands
重命名多个表Rename multiple tables .rename tables 进行一次调用Make a single call to .rename tables 不要为每对表发出单独的调用Don't issue a separate call for each pair of tables
显示命令Show commands 使用范围最小的 .show 命令Use the lowest-scoped .show command 不要在竖线 (|) 之后应用筛选器Don't apply filters after a pipe (|) 尽量限制使用。Limit use as much as possible. 如果可能,请缓存这些命令返回的信息。When possible, cache the information they return.
显示区Show extents 使用 .show table T extentsUse .show table T extents 不要使用 .show cluster extents | where TableName == 'T'Don't use .show cluster extents | where TableName == 'T'
显示数据库架构。Show database schema. 使用 .show database DB schemaUse .show database DB schema 不要使用 .show schema | where DatabaseName == 'DB'Don't use .show schema | where DatabaseName == 'DB'
显示具有大型架构的群集上的架构Show schema on a cluster which a large schema
使用 .show databases schemaUse .show databases schema 不要使用 .show schemaDon't use .show schema 例如,在数据库超过 100 个的群集上使用。For example, use on cluster with more than 100 databases.
检查表是否存在或获取表的架构Check a table's existence or get the table's schema 使用 .show table T schema as jsonUse .show table T schema as json 不要使用 .show table TDon't use .show table T 仅使用此命令来获取单个表的实际统计信息。Only use this command to get actual statistics on a single table.
定义将包含 datetime 值的表的架构Define the schema for a table that will include datetime values 将相关列设置为 datetime 类型Set the relevant columns to the datetime type 请勿在查询时将 string 或数值列转换为 datetime 进行筛选(如果这可以在引入之前或引入过程中完成)Don't convert string or numeric columns to datetime at query time for filtering, if that can be done before or during ingestion time
向元数据添加区标记Add extent tag to metadata 少量使用Use sparingly 避免使用 drop-by: 标记,这些标记限制了系统在后台执行面向性能的整理过程的能力。Avoid drop-by: tags, which limit the system's ability to do performance-oriented grooming processes in the background.
请参阅性能说明See performance notes.