I am using MySQL version 5.5.14 to run the following query from a table of 5 Million rows:
SELECT P.ID, P.Type, P.Name, P.cty
, X(P.latlng) as \'lat\', Y(P.
Good indexes are the ones with high selectivity. Your conditions are mostly range conditions and this poses a limit on the fields that can be used in a composite index.
Possible indexes to investigate (composed from those fields that have an equality check with the addition in the end, of one field with a range check):
(act, Type, tn, flA)
(act, Type, tn, cDate)
(act, Type, tn, nb)
To check selectivity without creating indexes, you could use:
SELECT COUNT(*)
FROM PIG P
WHERE act='1'
AND Type = 'g'
AND tn = 'l'
AND flA >= '1615'
and
SELECT COUNT(*)
FROM PIG P
WHERE act='1'
AND Type = 'g'
AND tn = 'l'
AND cDate >= NOW()
and
SELECT COUNT(*)
FROM PIG P
WHERE act='1'
AND Type = 'g'
AND tn = 'l'
AND nb <= '5'
and compare the output with the 742873
you have from the spatial index.