In a table with almost 50 million rows, there's a geography column.
I've already created a spatial index on that column and when I tried to execute the below query
SELECT
table_name.column_name.STDistance(geography::STPointFromText (('POINT(latidude longitude)'), 4326)) AS dist
FROM
table_name (nolock)
INNER JOIN
table_name_2 (nolock) ON (some conditions)
INNER JOIN
table_name_3 (nolock) ON (some conditions)
WHERE
geography::STPolyFromText (('POLYGON((latitude longitude))'), 4326).STContains(table_name.column_name) = 1
This query is running for a very long time.
Apart from the spatial index, is there something else I can do to improve the performance of this query?