Profiling
Without modifying the database
a) EXPLAIN without ANALYZE
EXPLAIN (VERBOSE)
SELECT loc3town.id AS loc3town_id,
loc3town.loc2zoneid AS loc3town_loc2zoneid,
loc3town.acronym AS loc3town_acronym,
loc3town.name AS loc3town_name,
loc3town.isactive AS loc3town_isactive,
loc3town."order" AS loc3town_order,
loc3town.officialcod AS loc3town_officialcod,
loc3town.datelast AS loc3town_datelast,
loc3town.lat AS loc3town_lat,
loc3town.lon AS loc3town_lon,
loc3town.osmid AS loc3town_osmid,
loc3town.osmname AS loc3town_osmname,
loc3town.osmplace AS loc3town_osmplace,
loc3town.locosmid AS loc3town_locosmid,
loc3town.isdummy AS loc3town_isdummy
FROM loc3town
WHERE loc3town.loc2zoneid = 50 ORDER BY loc3town.acronym asc
;
b) A transaction with a rollback
BEGIN;
EXPLAIN (ANALYZE, VERBOSE, BUFFERS)
SELECT loc3town.id AS loc3town_id,
loc3town.loc2zoneid AS loc3town_loc2zoneid,
loc3town.acronym AS loc3town_acronym,
loc3town.name AS loc3town_name,
loc3town.isactive AS loc3town_isactive,
loc3town."order" AS loc3town_order,
loc3town.officialcod AS loc3town_officialcod,
loc3town.datelast AS loc3town_datelast,
loc3town.lat AS loc3town_lat,
loc3town.lon AS loc3town_lon,
loc3town.osmid AS loc3town_osmid,
loc3town.osmname AS loc3town_osmname,
loc3town.osmplace AS loc3town_osmplace,
loc3town.locosmid AS loc3town_locosmid,
loc3town.isdummy AS loc3town_isdummy
FROM loc3town
WHERE loc3town.loc2zoneid = 50 ORDER BY loc3town.acronym asc;
ROLLBACK;
Modifying the database
EXPLAIN (ANALYZE, VERBOSE, BUFFERS)
SELECT loc3town.id AS loc3town_id,
loc3town.loc2zoneid AS loc3town_loc2zoneid,
loc3town.acronym AS loc3town_acronym,
loc3town.name AS loc3town_name,
loc3town.isactive AS loc3town_isactive,
loc3town."order" AS loc3town_order,
loc3town.officialcod AS loc3town_officialcod,
loc3town.datelast AS loc3town_datelast,
loc3town.lat AS loc3town_lat,
loc3town.lon AS loc3town_lon,
loc3town.osmid AS loc3town_osmid,
loc3town.osmname AS loc3town_osmname,
loc3town.osmplace AS loc3town_osmplace,
loc3town.locosmid AS loc3town_locosmid,
loc3town.isdummy AS loc3town_isdummy
FROM loc3town
WHERE loc3town.loc2zoneid = 50 ORDER BY loc3town.acronym asc
;