SQL-改善NOT EXISTS查询性能 [英] SQL - improve NOT EXISTS query performance

查看:390
本文介绍了SQL-改善NOT EXISTS查询性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以改善这种SQL查询性能:

Is there a way I can improve this kind of SQL query performance:

INSERT
INTO ...
WHERE NOT EXISTS(Validation...)

问题是,当我的表中有许多数据(如百万行)时,如果执行WHERE NOT EXISTS子句的速度很慢,则执行该命令.我必须执行此验证,因为我无法插入重复的数据.

The problem is when I have many data in my table (like million of rows), the execution of the WHERE NOT EXISTS clause if very slow. I have to do this verification because I can't insert duplicated data.

我使用SQLServer 2005

I use SQLServer 2005

thx

推荐答案

请确保您正在搜索索引列,并且没有对这些列中的数据(例如子字符串等)进行任何操作

Make sure you are searching on indexed columns, with no manipulation of the data within those columns (like substring etc.)

这篇关于SQL-改善NOT EXISTS查询性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆