Skip to content

Instantly share code, notes, and snippets.

@bkerley
Last active December 18, 2015 00:09
Show Gist options
  • Save bkerley/5694038 to your computer and use it in GitHub Desktop.
Save bkerley/5694038 to your computer and use it in GitHub Desktop.
SELECT
ST_AsText(wkb_geometry),
ST_Distance(wkb_geometry,
ST_PointFromText(
'POINT(-80.20228879999999 25.8012068)',
900914)),
ogc_fid,
globvalue,
units
FROM
nws_precip_1day_observed_20130601
WHERE
lat > 24.8012068 AND lat < 26.8012068 AND
lon > -81.20228879999999 AND lon < -79.20228879999999
ORDER BY
ST_Distance(wkb_geometry,
ST_PointFromText(
'POINT(-80.20228879999999 25.8012068)',
900914))
ASC
LIMIT 9;
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=381.03..381.05 rows=9 width=48)
-> Sort (cost=381.03..381.18 rows=60 width=48)
Sort Key: (st_distance(wkb_geometry, '010100002032BF0D003616B94CF20C54C033558BE31BCD3940'::geometry))
-> Bitmap Heap Scan on nws_precip_1day_observed_20130601 (cost=151.38..379.78 rows=60 width=48)
Recheck Cond: ((lat > 24.8012068) AND (lat < 26.8012068) AND (lon > (-81.20228879999999)) AND (lon < (-79.20228879999999)))
-> BitmapAnd (cost=151.38..151.38 rows=60 width=0)
-> Bitmap Index Scan on nws_precip_1day_observed_20130601_lat_idx (cost=0.00..45.25 rows=2098 width=0)
Index Cond: ((lat > 24.8012068) AND (lat < 26.8012068))
-> Bitmap Index Scan on nws_precip_1day_observed_20130601_lon_idx (cost=0.00..105.85 rows=4958 width=0)
Index Cond: ((lon > (-81.20228879999999)) AND (lon < (-79.20228879999999)))
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=219.64..219.66 rows=9 width=48)
-> Sort (cost=219.64..219.80 rows=63 width=48)
Sort Key: (st_distance(wkb_geometry, '010100002032BF0D003616B94CF20C54C033558BE31BCD3940'::geometry))
-> Index Scan using nws_precip_1day_observed_20130601_lat_lon_idx on nws_precip_1day_observed_20130601 (cost=0.00..218.33 rows=63 width=48)
Index Cond: ((lat > 24.8012068) AND (lat < 26.8012068) AND (lon > (-81.20228879999999)) AND (lon < (-79.20228879999999)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment