如何提高 nvarchar(max) 列的join效率
IF OBJECT_ID (N'StormyWeather', N'U') IS NOT NULL
DROP TABLE StormyWeather
GO
CREATE TABLE StormyWeather (
StormID INT NOT NULL IDENTITY,
StormHead NVARCHAR(50) NOT NULL,
StormBody NVARCHAR(MAX) NOT NULL,
)
GO
INSERT INTO StormyWeather (StormHead, StormBody)
VALUES('Stormy Weather Delays Travel',
'The stormy weather made travel by motor vehicle difficult.')
INSERT INTO StormyWeather (StormHead, StormBody)
VALUES('Stormier Weather on Monday',
'The stormier weather on Monday made vehicle travel difficult.')
INSERT INTO StormyWeather (StormHead, StormBody)
VALUES('Stormiest Weather in December',
'December can be the stormiest month, making automobile travel difficult.')
INSERT INTO StormyWeather (StormHead, StormBody)
VALUES('Storm Grows Strong',
'The storm is growing strong.')
INSERT INTO StormyWeather (StormHead, StormBody)
VALUES('Storms Crossing the Pacific',
'The storms are lining up across the Pacific Ocean.')
INSERT INTO StormyWeather (StormHead, StormBody)
VALUES('Storm''s Wind Delays Travel',
'The storm''s wind made car travel difficult on Tuesday.')
INSERT INTO StormyWeather (StormHead, StormBody)
VALUES('Storms'' Flooding Delays Travel',
'The storms'' flooding made auto travel difficult throughout December.')
INSERT INTO StormyWeather (StormHead, StormBody)
VALUES('Children Run from Room',
'The children often storm out of the room when upset.')
INSERT INTO StormyWeather (StormHead, StormBody)
VALUES('Boy Runs from Room',
'The boy storms out of the room when his sister changes the channel.')
INSERT INTO StormyWeather (StormHead, StormBody)
VALUES('Girl Ran from Room',
'The girl stormed out of the room when her brother ate the cookie.')
INSERT INTO StormyWeather (StormHead, StormBody)
VALUES('Children Running from Room',
'The children were storming out of the room when the lights went out.')
GO
create table #1 (
StormID INT NOT NULL IDENTITY,
StormHead NVARCHAR(50) NOT NULL,
StormBody NVARCHAR(MAX) NOT NULL,
)
go
INSERT INTO #1 (StormHead, StormBody)
VALUES('Boy Runs from Room',
'The boy storms out of the room when his sister changes the channel.')
INSERT INTO #1 (StormHead, StormBody)
VALUES('Girl Ran from Room',
'The girl stormed out of the room when her brother ate the cookie.')
INSERT INTO #1 (StormHead, StormBody)
VALUES('Children Running from Room',
'The children were storming out of the room when the lights went out.')
我的问题是如何提高如下链接的join顺序
select * from StormyWeather a join #1 b on a.StormBody = b.StormBody
需要补充的是
1. nvarchar(max)类型上 没办法加索引,
2.使用全文索引的话,好像没法支持 join操作
3.数据量是千万级或更高,单个表的大小目前大约10G,
4.这个查询只是个例子,用的最多的是在存储过程中,往表中插入此表没有的数据,其中判断条件中有这种大的列。
多谢多谢。。。
...全文
相关推荐
sqlserver中在指定数据库的所有表的所有列中搜索给定的值
最近因ERP项目,我们需要知道前台数据导入功能Application操作的导入字段都写入到了后台数据库哪些表的哪些列
Sql Server中判断表、列不存在则创建的方法
一、Sql Server中如何判断表中某列是否存在 首先跟大家分享Sql Server中判断表中某列是否存在的两个方法,方法示例如下: 比如说要判断表A中的字段C是否存在两个方法: 第一种方法 IF EXISTS ( SELECT 1 FROM SYSOBJECTS T1 INNER JOIN SYSCOLUMNS T2 ON T1.ID=T2.ID WHERE T1.NAME='A' AND T2.NAME='C' ) PRINT '存在' ELSE PRINT '不存在' 第二种方法,短小精悍,可谓精典 IF COL_LENGTH('A', 'C') I
整个数据库内字符串搜索
可以在数据库中查找到一个特定的字符串,下载后把:您要查找的东西,改为要找的即可
自己写的sql server资料
word文档 自己写的sql server资料
SqlServer性能优化高效索引指南
性能不够,索引来凑 性能不好,建个索引就会好? 索引一定能提升性能? 高效索引指南 提高索引的存储效率 选择合适的索引 减少二次查找 ...


