简体   繁体   English

使用MapGuide Open Source 2.1的SQL Server 2008空间索引和CPU利用率

[英]SQL Server 2008 spatial index and CPU utilization with MapGuide Open Source 2.1

I have a SQL Server table with hundreds of thousands of geometry type parcels. 我有一个包含成千上万个几何类型宗地的SQL Server表。 I have made indexes on them trying different combinations of density and objects per cell settings. 我对它们进行了索引,每个单元设置尝试使用密度和对象的不同组合。 So far I'm settiling for LOW, LOW, MEDIUM, MEDIUM and 16 objects per cell and I made a SP that sets the bounding box according to the extents of the entities in the table. 到目前为止,我为每个像元设置LOW,LOW,MEDIUM,MEDIUM和16个对象,并制作了一个SP,用于根据表中实体的范围设置边界框。

There is an incredible performance boost from queries taking almost minutes without index to less than seconds, it gets faster when the zoom is closer thus less objects are displayed. 查询几乎不需要索引就可以花费几分钟到不到几秒钟,从而极大地提高了性能,当缩放越近,显示的对象越少,查询速度就会更快。

Yet the CPU utilization gets to 100% when querying for features, even when the queries themselves are fast. 但是,即使查询本身很快,在查询功能时,CPU利用率也可以达到100%。 I'm worrying this will not fly in a production environment. 我担心这在生产环境中不会奏效。

I am using MapGuide Open Source 2.1 for this project, but I am positive the CPU load is caused by SQL Server. 我正在为此项目使用MapGuide Open Source 2.1,但我肯定CPU负载是由SQL Server引起的。

I wonder if my indexes are set properly. 我想知道我的索引设置是否正确。 I haven't found any clear documentation on how to properly set them up. 我没有找到任何有关如何正确设置它们的清晰文档。 Every article I've read basically says "it depends..." but nothing specific. 我读过的每一篇文章基本上都说“取决于...”,但没有具体说明。 Do you have any recommendations for me, including books, articles? 您对我有什么建议,包括书籍,文章?

Thank you. 谢谢。

Is the CPU utilization at SQL or on the mapguide daemon? 是SQL还是mapguide守护程序上的CPU使用率?

One of the issues we ran into is that mapguide isn't that smart about writing queries. 我们遇到的问题之一是mapguide在编写查询方面不是那么聪明。 If your at maximum zoom and displaying a small subset of a legend (say only transmission at that zoom level) it will query every object within the view area without applying any other filter. 如果以最大缩放比例显示图例的一小部分(例如,仅以该缩放级别传输),它将查询视图区域内的每个对象,而无需应用任何其他过滤器。 It then loops through thousands of records and applies the theme (which uses a separate filter). 然后,它遍历数千条记录并应用主题(使用单独的过滤器)。

What you could try doing is writing layers for different zoom levels and use the query filter to limit the amount of data returned from SQL (which is probably what is taking so much CPU time). 您可以尝试做的是为不同的缩放级别编写图层,并使用查询过滤器来限制从SQL返回的数据量(这可能会占用大量CPU时间)。 This reduced the initial load time on our transmission and distribution lines (the only stuff that makes sense to display at that level) down to a few milliseconds, compared to 20+ seconds. 这将我们的输电和配电线路(唯一可以在该级别显示的东西)上的初始加载时间降低了几毫秒,而不是20秒钟以上。

-- -

What I was talking about is making sure you are only requesting data that the layer needs. 我所说的是确保您仅请求该层需要的数据。 Say you display ids 1, 2, 3, and 4. 假设您显示ID 1、2、3和4。

Say you have display 1 and 2 at scales 0 -> infinity. 假设您以0->无穷大的比例显示1和2。 While 3 and 4 only kicks in at say 20,000 feet. 而3和4仅在20,000英尺处踢球。 By default mapguide will basically do a select * with a bounding box of the viewport. 默认情况下,mapguide基本上会对视口的边界框执行select *。 Then it will loop through all of the data applying the theme. 然后它将遍历应用该主题的所有数据。

So at say 30,000 feet it will query all data, but still need to loop through it. 因此,在30,000英尺的高度,它将查询所有数据,但仍然需要遍历它。

the simple answer is to generalise your data, so it's optimised for display 简单的答案是对数据进行概括,因此针对显示进行了优化

ie create some additional tables which have less detail and is less dense 即创建一些其他表,这些表的详细信息较少且密度较小

Any time you have this kind of question, it's time to pull out SQL Profiler and see what queries are being executed. 每当您遇到此类问题时,就该抽出SQL Profiler并查看正在执行哪些查询。 Then run them through the query planner to see where the bottlenecks are. 然后通过查询计划程序运行它们以查看瓶颈在哪里。

You could also be lazy (like me) and just record a typical load using the Tuning Template, and run it through the Database Engine Tuning Advisor to see where it thinks you could add indices to improve performance. 您也可以像我一样懒惰,只使用Tuning Template记录典型的负载,然后通过Database Engine Tuning Advisor运行它,以查看它认为可以添加索引以提高性能的位置。

Normally, you'd also be in a position to optimize the queries that are being run against the server, but you're a bit short of options when it comes to MapGuide; 通常,您还可以优化针对服务器运行的查询,但是对于MapGuide而言,您的选择有些不足; it may be that MapGuide is asking the questions in a way that's hard for SQL Server to optimize. MapGuide可能以SQL Server无法优化的方式询问问题。 If you find this to be the case, please enter a ticket in the MapGuide Trac system 如果发现这种情况,请在MapGuide Trac系统中输入票证

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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