for a query like this:
WITH params as (SELECT -28 as lat, 151 as lon
FROM dual)
SELECT sighting_id, sqrt(power(lat - latitude, 2) + power(lon - longitude, 2))
AS distance FROM sightings CROSS JOIN params
WHERE sqrt(power(lat - latitude, 2) + power(lon - longitude, 2)) =
(SELECT MAX(sqrt(power(lat - latitude, 2) + power(lon - longitude, 2)))
FROM sightings CROSS JOIN params);
how exactly would i go about building a function based index on it? sighting_id is the primary key, does this mean id have to build it on the long and lats? ive looked a up some examples but none really seem to show me how id go about building one here.
the execution plan is as follows:
id operation name
0 select statement
1 table access full sighting
2 sort aggregate
3 table access full sighting