本文介绍了SQL服务器,这些选择的性能和差异是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好, 我正在寻找一种在给定数据库中查找的方法,如果有一个表符合特定名称的列。经过研究和与同事交谈后,出现了两种可能的解决方案:
Hello, I was looking into a way to find in a given database if there were any table if a column that matched a specific name. After researching and talking to colleagues these two possible solution have arisen:
SELECT table_name ,column_name FROM information_schema.columns WHERE column_name like '%word%'和
And
SELECT t.name AS TableName ,c.name AS ColName FROM sys.columns c JOIN sys.tables t ON c.object_id = t.object_id WHERE c.name LIKE '%word%'它们之间是否存在性能差异?什么时候?有关如何改进它的任何建议吗? thx
Is there a performance difference between them? when? Any suggestions on how to improve it? thx
推荐答案我在SQL Server Management中测试了两个查询工作室。 我打开了包含实际执行计划。 第一个查询需要一次连接和两次索引搜索/扫描。 第二个查询需要三个连接和四个索引搜索/扫描。 I tested both queries in SQL Server Management Studio. I turned on "Include Actual Execution Plan". The first query required one join and two index seeks/scans. The second query required three joins and four index seeks/scans.
更多推荐
SQL服务器,这些选择的性能和差异是什么?
发布评论