Wednesday, June 4, 2008

Exploring Table and Index Partitioning in SQL Server 2005

参考 http://www.sqljunkies.com/article/f4920050-6c63-4109-93ff-c2b7eb0a5835.scuk

Indexed Views in SQL Server 2000

参考 http://www.sqlteam.com/article/indexed-views-in-sql-server-2000

When and where do we use hash index in sql server

参考http://www.fotia.co.uk/fotia/Blog/2006/01/hash-indexes.html
当我设计一个Product表的时候, 对于ProductName这个字段的数据类型, 我一直拿捏不定, 最后为了不至于ProductName被截断, 我选用了NVarchar(4000), 我没有选择Text(NText)类型, 因为在SQL Server 2005中,它们被标记为Deprecated.
幸运的是,我选取了NVarchar(4000), 在实际情况下, 有个名称也确实够长, 足足1000个byte.
同时我又需要在ProductName上创建Index, 对于length>=900byte的字段, 将SQL Server拒绝为你创建普通的index.
怎么办呢? 我们可以为ProductName这样的长字段, 创建Hash Index, 方法是:
第一步, 为Product表创建一个计算列, 比如ProductNameHashField, 让它的值为CheckSum(ProductName), 这个字段的值将是Integer类型.
第二步, 创建一个ProductNameHashField字段的Index, 名为IX_Product_NameHash


-- Index it. Note that this is a non-unqiue index for collisions.
create index IX_Product_NameHash
on Product(ProductNameHashField);
go

怎么利用这个Hash Index, 来加速我们的query呢?


-- Look for the hash of the DName.
-- Always, always include the original data in case of collisions.
select customerId
from Product
where ProductNameHashField= checksum(@ProductName)-- this is the key to speed up query
and ProductName= @ProductName
go

通过观察执行计划, 发现查询速度确实有了很大的提高.

sqlite provider for ado.net

ado.net 2 dll download
http://sqlite.phxsoftware.com/

http://sourceforge.net/projects/sqlite-dotnet2

SQL Server management studio(sp2)

SQL Server management studio Express版本是Free的. 在SP2之前是不能进行管理SQL Server Compact 数据库的, SP2版本可以管理Compact数据库.

Download URL: http://www.microsoft.com/downloads/details.aspx?FamilyID=6053C6F8-82C8-479C-B25B-9ACA13141C9E&displaylang=en

SQL Server Express vs Compact Edition

面对Sybase和SQLite和Firebird以及VistaDB的竞争,SQL Server也推出了Compact版本, 它是比Express版本更加小巧的版本.
Express版本是用来代替以前的MSDE(Desktop Edition)的. 它是标准的C/S架构.
而Compact版本可以认为是文件数据库, 它的支持dll仅需要1.5M. 没有专门的log文件.

但Compact版本不像其他版本的SQL Server拥有丰富的SQL 语句. 比如它不支持Select Intersect/Except等操作.

Sqlite admin tools

1. SQLite Spy (http://www.yunqa.de/delphi/sqlitespy/),一个非常不错的SQLite Database Explorer and Query Analyzer。不需要安装。支持Unicode, 比较适合查询.
2. sqliteadmin http://sqliteadmin.orbmu2k.de/
包括structure定义向导, 比较适合数据库定义. 刚推出了支持Unicode的beta版本
3. Firefox Addon- SQLite Manager, 可以定义Table, 也可以进行查询, 它还有一个非常好的特点是, 能够让你有机会设置很多DB全局变量, 比如Cache size和page Size等等.