在SQL Server中选择几何列数据需要更多时间。

编程入门 行业动态 更新时间:2024-10-23 13:31:15
本文介绍了在SQL Server中选择几何列数据需要更多时间。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

Hi,

declare @points nvarchar(500)='POINT(-76.5921662 39.2674632)' SELECT * FROM [NeighborhoodsTable] WHERE [NbhoodPolygon].MakeValid().STIntersects(geometry::STGeomFromText(@points, 4326)) =1

此查询需要20秒。 NbhoodPolygon列数据类型是几何。 在我的数据库中有2万卢比的记录。 帮帮我Plz ... 我尝试过: 我需要优化查询,我想快速得到结果。

推荐答案

首先不要使用SELECT *。指定要在查询中返回的列,或SQL需要执行另一个查询以获取列名。 其次,使用数据库引擎优化顾问确定查询需要索引 - 它位于SQL>>下的Windows开始菜单上性能工具 通常可以通过选择查询然后右键单击来完成,也可以使用SQL事件探查器来捕获查询的跟踪。 您还可以使用SQL Management Studio中的选项包括实际执行计划。这通常会建议缺少索引,但它不如调整向导有效。 这两种方法都不是万无一失,也不考虑您的典型工作量。阅读索引以获取有关在盲目应用建议和测试实际工作负载之前需要考虑的内容的其他信息 - 当表数据发生变化时,索引需要更新,这可能会对性能产生负面影响。 亲切的问候 Firstly do not use SELECT *. Specify the columns you want to return in your query or SQL needs to perform another query to get the column names. Secondly, use the Database Engine Tuning Adviser to determine what indexes are required for the query - it is on the Windows Start Menu under SQL >> Performance Tools This can be also normally be done by selecting your query & then right-clicking or can also be done by using SQL Profiler to capture a trace of the query. You can also use the option in SQL Management Studio to "Include actual execution plan". This will often advise of missing indexes but it is not as effective as the Tuning Wizard. Neither method is foolproof nor do they take into account your typical workload. Read up on Indexing for additional information on what you need to take into account before blindly applying recommendations & test against real workloads - indexes need to be updated when the table data is changed & this may negatively affect performance. Kind Regards

更多推荐

在SQL Server中选择几何列数据需要更多时间。

本文发布于:2023-11-26 20:09:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1635014.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:几何   时间   更多   数据   SQL

发布评论

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

>www.elefans.com

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