문제

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