datetime字段上的azure sql索引策略

datetime字段上的azure sql索引策略,sql,indexing,azure-sql-database,Sql,Indexing,Azure Sql Database,我在表(sql azure)中有两个datetimeoffset字段,Migrated和Updated 我通常在迁移的表中搜索select*from

我在表(sql azure)中有两个
datetimeoffset
字段,
Migrated
Updated

我通常在迁移的表中搜索
select*from

为这些字段编制索引的正确策略是什么

  • 两个索引,每个字段一个
  • 已迁移
    已更新
  • 更新
    迁移

  • 表很大,需要索引…

    在大多数SQL Server版本中,您可以采用以下方法。我没有在SQLAzure中尝试过这个

    创建计算列,然后在此列上创建索引:

    alter table t add MigratedToUpdatedTime as (datediff(seconds, Migrated, Updated))
    
    create index t_MigratedToUpdatedTime on t(MigratedToUpdatedTime);
    
    然后在
    where
    子句中,您可以执行以下操作:

    where MigratedToUpdatedTime > 0;
    

    这很有帮助!!!我还使用了这些帖子来实现Gordon提出的想法