SQL服务器,这些选择的性能和差异是什么?

编程入门 行业动态 更新时间:2024-10-09 18:19:02
本文介绍了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服务器,这些选择的性能和差异是什么?

本文发布于:2023-11-09 23:35:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1573751.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:差异   性能   服务器   SQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!