• I am not an expert on Spatial data, but I do know a few things:

    * The reply by Ville-Pekka is incorrect. I think he is confusing two features. Indexed views is the only feature that works automatically in enterprise but needs hints in lower editions; all other features either work automatically on all editions, or don't work at all on lower features.

    * Are you running on SQL Server 2008? If so, check SELECT @@VERSION to see what, if any, service pack you have installed. If you are on RTM, that might be the cause - there were some huge imprevements to the costing of spatial queries that solved a lot of issues with spatial indexes not being used in SP1. See http://www.sqlskills.com/blogs/bobb/how-to-ensure-your-spatial-index-is-being-used/[/url].

    * Other things that might help are simplfying the query (break it down in subqueries if needed), and executing it in such a way that the optimizer "knows" the parameter value. You may also need to add a recompile hint, to prevent parameter sniffing issues.

    I do agree with Ville-Pekka that posting the execution plan would help. And the full query or stored procedure.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/