简体   繁体   中英

SQL Server DELETE OPENQUERY performance

We have a series of programs that are designed to move data from one SQL Server database into another using OPENQUERY and database linked servers.

We are noticing that queries such as the following are taking orders magnitude long than anticipated.

DELETE OPENQUERY(server, 'SELECT * FROM table WHERE pkf1 = ''v1'' AND pkf2 = ''v2''')

For example, if the above was rewritten as:

exec('DELETE * FROM table WHERE pkf1 = ''v1'' and pkf2 = ''v2''') at server

or

DELETE FROM server.schema.table WHERE pkf1 = 'v1' and pkf2 = 'v2'

the performance is only a few seconds compared to minutes using OPENQUERY .

Can someone explain why the OPENQUERY approach is so inefficient by comparison? Does it not use the primary key indexes?

与简单查询(例如DELETE)相比,开放查询具有更好的处理程序,并且查询可以在远程服务器中解析

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM