From cc5095b162878999746d983162e3f02cc7b48e80 Mon Sep 17 00:00:00 2001 From: Dan White Date: Sun, 25 Dec 2022 22:43:24 -0600 Subject: [PATCH] update SQL analysis --- observations_analysis.sqbpro | 45 +++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/observations_analysis.sqbpro b/observations_analysis.sqbpro index 29e5ba6..9bfdcdf 100644 --- a/observations_analysis.sqbpro +++ b/observations_analysis.sqbpro @@ -1,21 +1,21 @@ -
-- Indexes make the world go 'round ... faster. -create index if not exists gs_norad_index -on observations(ground_station, norad_cat_id); +
-- Indexes make the world go 'round ... faster. +CREATE INDEX IF NOT EXISTS gs_norad_index +ON observations(ground_station, norad_cat_id); -create index if not exists gs_index -on observations(ground_station); +CREATE INDEX IF NOT EXISTS gs_index +ON observations(ground_station); -create index if not exists norad_index -on observations(norad_cat_id); +CREATE INDEX IF NOT EXISTS norad_index +ON observations(norad_cat_id); -create index if not exists observer_index -on observations(observer); +CREATE INDEX IF NOT EXISTS observer_index +ON observations(observer); -create index if not exists observer_gs_index -on observations(observer, ground_station); +CREATE INDEX IF NOT EXISTS observer_gs_index +ON observations(observer, ground_station); -create index if not exists gs_observer_index -on observations(ground_station, observer); +CREATE INDEX IF NOT EXISTS gs_observer_index +ON observations(ground_station, observer); -- Special index for speeding up time range queries. CREATE VIRTUAL TABLE IF NOT EXISTS times_index USING rtree(id, start, end); @@ -61,10 +61,18 @@ FROM observations WHERE vetted_status = "unknown" GROUP BY observer ORDER BY num_unknown;-- Which satellites are listened to by which GS? -select ground_station, norad_cat_id, count(id) from observations +SELECT + ground_station, + norad_cat_id, + count(id) AS num_obs +FROM observations GROUP BY ground_station, norad_cat_id ORDER BY ground_station, count(id);-- Favorite ground stations used by observers -select observer, ground_station, count(id) from observations +SELECT + observer, + ground_station, + count(id) AS num_obs +FROM observations GROUP BY observer, ground_station ORDER BY observer, count(id) DESC, ground_station; -- Observations on each ground station, by total number per observer @@ -72,9 +80,8 @@ ORDER BY observer, count(id) DESC, ground_station; SELECT ground_station, observer, - count(id) + count(id) AS num_obs FROM observations -WHERE ground_station = 2 GROUP BY ground_station, observer ORDER BY ground_station, count(id) DESC, observer; -- How many different observers have scheduled on each GS? @@ -89,8 +96,8 @@ ORDER BY ground_station; SELECT observer, count(distinct ground_station) AS num_gs, -count(id) AS num_obs + count(id) AS num_obs FROM observations GROUP BY observer ORDER BY num_gs DESC; -
+
-- 2.25.1