Skip to content

Instantly share code, notes, and snippets.

@workmaster2n
Last active August 29, 2015 13:57
Show Gist options
  • Save workmaster2n/9572948 to your computer and use it in GitHub Desktop.
Save workmaster2n/9572948 to your computer and use it in GitHub Desktop.
SELECT DISTINCT("tracked_points"."decisecond_recorded_at")
FROM "tracked_points" WHERE
"tracked_points"."decisecond_recorded_at" >= 1393987371
ORDER BY decisecond_recorded_at
-- Table: tracked_points
-- DROP TABLE tracked_points;
CREATE TABLE tracked_points
(
id serial NOT NULL,
recorded_at timestamp without time zone,
worker_id integer,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
location_id integer NOT NULL,
session_id integer,
frequency integer,
worker_id_checked_at timestamp without time zone,
geom postgis.geometry(PointZ),
zone_checked_at timestamp without time zone,
decisecond_recorded_at numeric(32,1),
CONSTRAINT tracked_points_pkey PRIMARY KEY (id)
)
WITH (
OIDS=FALSE
);
ALTER TABLE tracked_points
OWNER TO arcsite;
-- Index: index_tracked_points_on_decisecond_recorded_at
-- DROP INDEX index_tracked_points_on_decisecond_recorded_at;
CREATE INDEX index_tracked_points_on_decisecond_recorded_at
ON tracked_points
USING btree
(decisecond_recorded_at);
-- Index: index_tracked_points_on_geom
-- DROP INDEX index_tracked_points_on_geom;
CREATE INDEX index_tracked_points_on_geom
ON tracked_points
USING gist
(geom);
-- Index: index_tracked_points_on_recorded_at
-- DROP INDEX index_tracked_points_on_recorded_at;
CREATE INDEX index_tracked_points_on_recorded_at
ON tracked_points
USING btree
(recorded_at);
-- Index: index_tracked_points_on_worker_id
-- DROP INDEX index_tracked_points_on_worker_id;
CREATE INDEX index_tracked_points_on_worker_id
ON tracked_points
USING btree
(worker_id);
-- Index: index_tracked_points_on_worker_id_checked_at
-- DROP INDEX index_tracked_points_on_worker_id_checked_at;
CREATE INDEX index_tracked_points_on_worker_id_checked_at
ON tracked_points
USING btree
(worker_id_checked_at);
-- Index: index_tracked_points_on_zone_checked_at
-- DROP INDEX index_tracked_points_on_zone_checked_at;
CREATE INDEX index_tracked_points_on_zone_checked_at
ON tracked_points
USING btree
(zone_checked_at);
-- Index: index_tracked_points_partial_zone_checked_at
-- DROP INDEX index_tracked_points_partial_zone_checked_at;
CREATE INDEX index_tracked_points_partial_zone_checked_at
ON tracked_points
USING btree
(zone_checked_at);
explain analyze
SELECT DISTINCT ON ("tracked_points"."decisecond_recorded_at") decisecond_recorded_at, recorded_at
FROM "tracked_points" WHERE
"tracked_points"."decisecond_recorded_at" >= 1393987371
ORDER BY decisecond_recorded_at
@workmaster2n
Copy link
Author

slow_query_explain_analyze: http://explain.depesz.com/s/d6T

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment