Skip to content

Instantly share code, notes, and snippets.

@kofronpi
Created April 13, 2018 13:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kofronpi/4b1fba2d4cdfbfbaa6880e69482274f2 to your computer and use it in GitHub Desktop.
Save kofronpi/4b1fba2d4cdfbfbaa6880e69482274f2 to your computer and use it in GitHub Desktop.
another_query_attempt
EXPLAIN ANALYZE
SELECT DISTINCT ON (a.activite_principale)
a.activite_principale,
a.id,
a.nom_raison_sociale
FROM geo_data.etablissements AS a
WHERE a.activite_principale IN ('1071C', '4711D', '4773Z', '5914Z')
ORDER BY a.activite_principale,
a.geom <-> 'SRID=4326;POINT (-0.07653031474222297 43.45283273235598)'::geometry;
Unique (cost=89055.26..89107.72 rows=568 width=38) (actual time=1023.374..1035.724 rows=4 loops=1)
-> Sort (cost=89055.26..89081.49 rows=52462 width=38) (actual time=1023.372..1028.782 rows=75461 loops=1)
Sort Key: activite_principale, ((geom <-> '0101000020E6100000626EF89E7D97B3BF7D03486CF6B94540'::geometry))
Sort Method: quicksort Memory: 9636kB
-> Bitmap Heap Scan on etablissements a (cost=369.67..88232.70 rows=52462 width=38) (actual time=27.085..870.292 rows=75461 loops=1)
Recheck Cond: ((activite_principale)::text = ANY ('{1071C,4711D,4773Z,5914Z}'::text[]))
Heap Blocks: exact=69180
-> Bitmap Index Scan on "index_geo_data.etablissements_on_activite_principale" (cost=0.00..367.04 rows=52462 width=0) (actual time=13.345..13.345 rows=75461 loops=1)
Index Cond: ((activite_principale)::text = ANY ('{1071C,4711D,4773Z,5914Z}'::text[]))
Planning time: 0.222 ms
Execution time: 1035.784 ms
(11 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment