Вопрос

I have a SQL Server 2012 database with 3 mln company records in which you can search by using some where like clauses on name and address fields. This works pretty fast.

Now I'm extending this query with an optional point + distance parameter. When these parameters are used, the query uses them.

Now, searching on just the varchar columns works really fast. Searching on only lat / long (point) + distance is also fast. But when I combine the two, it becomes really slow.

Any idea on what I could be doing wrong, or how I should setup my indexes?

Right now i have these indexes:

PK_CompanyId (The standard index that came with the primary key)

IX_CompanyData (Index on the VARCHAR Fields that are being searched And this index has the Lat & Long column in it's included columns)

Это было полезно?

Решение

Started solving my problem by first narrowing my search results on the lat/long values from the cities which the companies are linked to. This made a huge difference in performance.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top