我在SQL Server 2005中有一个表,其中有大约40亿行.我需要删除大约20亿这些行.如果我尝试在单个事务中执行此操作,则事务日志将填满并且失败.我没有任何额外的空间来使事务日志更大.我认为最好的方法是批量删除语句(批量为~10000?).
我可以使用游标执行此操作,但这是一种标准/简单/聪明的方法吗?
PS此表没有标识列作为PK.PK由整数外键和日期组成.
我试图首次对预先存在的数据库自动生成一个alembic修订版,但是当我运行以下命令时
alembic revision --autogenerate
Run Code Online (Sandbox Code Playgroud)
它会生成一个迁移,尝试在我的数据库中创建每个表和索引.与此类似:
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.create_table('table1',
sa.Column('id', sa.SmallInteger(), nullable=False),
sa.Column('name', sa.String(length=100), nullable=True),
sa.Column('desc', sa.Text(), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('name'),
schema='schema1'
)
op.create_index(op.f('ix_index1'), 'table1', ['name'], unique=False, schema='schema1')
... all my other tables/indexes ..
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_index1'), table_name='table1', schema='schema1')
op.drop_table('table1', schema='schema1')
... all my other tables/indexes ..
Run Code Online (Sandbox Code Playgroud)
然后,如果我尝试运行迁移,它将失败,因为对象已经存在:
sqlalchemy.exc.ProgrammingError: (ProgrammingError) relation "table1" already exists
Run Code Online (Sandbox Code Playgroud)
所以在我看来,像alembic认为我的数据库不包含任何表,但确实如此.
任何想法为什么会这样?
有没有人知道一个资源,它将告诉我在SQL Server 2005中的select/insert/update/delete期间将在表/ page/row/index上取出的锁序列以及不同的表提示和隔离级别将如何影响锁采取?
我知道我在这里问了很多,但肯定这些信息必须记录在某处?
提前致谢,
汤姆
我正在尝试发布如下所示的消息
_bus.Publish(new BatchCompleted { BatchId = batch.Id});
Run Code Online (Sandbox Code Playgroud)
并在BatchCompletedHandler中处理它:
public class BatchCompletedHandler: IHandleMessages<BatchCompleted>
{
public void Handle(BatchCompleted message)
{
Do Some Stuff...
}
}
Run Code Online (Sandbox Code Playgroud)
每当我尝试发布消息时,我都会收到以下System.Exception:
找不到'MyAssembly.BatchCompleted'的元数据.消息需要实现"IMessage","IEvent"或"ICommand".或者,如果您不想实现接口,则可以配置"Unobtrusive Mode Messages"并使用约定来配置消息的映射方式.
该消息确实实现了IEvent,如下所示
[Serializable]
public class BatchCompleted : IEvent
{
public int BatchId{ get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我正在使用以下代码配置NSB
Configure.With(MyAssembly)
Run Code Online (Sandbox Code Playgroud)
消息处理程序位于程序集MyAssembly中,消息位于MyMessagesAssembly中.
我究竟做错了什么?
在哪里可以找到有关SQL Server 2005中调优统计信息的一些深入信息?
我需要真正深入研究在许多不同查询中使用的统计信息,它们如何与索引交互,如何/何时/何处使用自定义统计信息(超出数据库调优顾问建议的内容),何时/如何更新统计数据以获得最佳表现等.
有谁知道围绕这个主题的任何好文章/网络广播/书籍?
提前致谢,
汤姆
sql-server ×3
.net ×1
alembic ×1
messaging ×1
nservicebus ×1
python ×1
sql ×1
statistics ×1
t-sql ×1