sql – 高写入(10000次插入/小时),低读取(10次读取/秒)的最佳数据库?

我正在开发一个Web应用程序,目前正在使用sql server 2008.但是,我正在考虑转移到另一个数据库(simpledb)以提高性能.

我有一个后台进程,每小时最多10000行插入一个特定的表.该表也被读取以显示Web应用程序中的数据.后台进程运行时,Web应用程序无法使用,因为数据库连接超时.

因此,我正在考虑转向亚马逊的simpledb来提高性能.亚马逊的SimpleDB是否针对此用例进行了优化?如果没有,我可以使用另一种解决方案吗?

解决方法

您的问题是您正在使用的隔离级别.除非您更改它,否则sql Server(以及许多其他数据库)将以选择将阻止未提交读取的模式运行.您想要更改sql Server,使其使用 MVCC(Oracle的默认设置; MysqLsql Server也都使用它),您的问题将消失.

SET TRANSACTION ISOLATION LEVEL (Transact-SQL)开始:

READ COMMITTED

Specifies that statements cannot read
data that has been modified but not
committed by other transactions. This
prevents dirty reads. Data can be
changed by other transactions between
individual statements within the
current transaction,resulting in
nonrepeatable reads or phantom data.
This option is the sql Server default.

The behavior of READ COMMITTED depends
on the setting of the
READ_COMMITTED_SNAPSHOT database
option:

  • If READ_COMMITTED_SNAPSHOT is set to OFF (the default),the Database Engine
    uses shared locks to prevent other
    transactions from modifying rows while
    the current transaction is running a
    read operation. The shared locks also
    block the statement from reading rows
    modified by other transactions until
    the other transaction is completed.

    The shared lock type determines when
    it will be released. Row locks are
    released before the next row is
    processed. Page locks are released
    when the next page is read,and table
    locks are released when the statement
    finishes.
  • If READ_COMMITTED_SNAPSHOT is set to ON,the Database Engine uses row
    versioning to present each statement
    with a transactionally consistent
    snapshot of the data as it existed at
    the start of the statement. Locks are
    not used to protect the data from
    updates by other transactions.

When the READ_COMMITTED_SNAPSHOT
database option is ON,you can use the
READCOMMITTEDLOCK table hint to
request shared locking instead of row
versioning for individual statements
in transactions running at the READ
COMMITTED isolation level.

(重点补充)

更改数据库配置以将READ_COMMITTED_SNAPSHOT变为ON.

此外,尽量保持您的事务尽可能短,并确保您在后台进程中提交事务(每小时执行10,000次插入),因为如果它从未提交,则选择将永久阻止(在默认设置下).

相关文章

(一)日志传送架构 (1.1)相关服务器 主服务器 :用于生产的服务器,上面运行这生产SQL Server数据库...
(一)事故背景 最近在SQL Server 2012生产数据库上配置完事物复制(发布订阅)后,生产数据库业务出现了...
(一)测试目的 目前公司使用的SQL SERVER 2012高可用环境为主备模式,其中主库可执行读写操作,备库既...
(一)背景个人在使用sql server时,用到了sql server的发布订阅来做主从同步,类似MySQL的异步复制。在...
UNION和OR谓词 找出 product 和 product2 中售价高于 500 的商品的基本信息. select * from product wh...
datawhale组队学习task03