Marc-André Bombeck
4e79098cc0
perf(measurements): fold per-source days without joining a regrouping back
...
Three readers grouped the same rows twice and joined the second grouping
back to the first: the live buckets joined each hourly-mean day's hour
means to the per-source days, the all-time extremes joined the day
weights the same way, and the doctor report's dense buckets joined each
bucket's latest reading and hour means to the bucket aggregates. On a
measurements table without planner statistics (a new install, or an
import under the autoanalyze threshold) the planner estimated one row on
each side and ran every one of those joins as a nested loop that re-ran
the inner grouping for each outer row.
On ten years of readings over six types (51,000 rows, no statistics) the
dense buckets and the every-type live buckets ran into the 60 s statement
timeout and the all-time extremes took 11 s. With statistics all three
answered in 0.1 to 0.2 s.
Each is now one chain of folds over one scan. The live buckets fold the
readings per local hour and the hours per local day, carrying the day of
hours beside the counts. The all-time extremes take the day weights from
the same windowed rows they count, the shape the pre-fold remainder
already has. The dense buckets carry each bucket's latest reading and each
hour's count and mean on the rows as window values, and one grouping folds
them all. Same fixture without statistics: 0.2 s, 0.1 s and 0.1 s, the same
as with them.
A parity suite runs the joined statements as the reference against the
readers across ladders, zones with whole, half-hour and negative offsets,
grains, overlapping and off-ladder sources, glucose contexts and device
types, tombstones and both DST changes; sums and means agree to
floating-point summation order, everything else exactly. The
unanalysed-table guard now runs the three readers under EXPLAIN ANALYZE:
the joins measured 200 to 3,000 row visits per row stored, the folds about
10.
The dense-bucket loader drops under the 200-line function cap, so its
baseline entry goes.
2026-10-25 06:27:44 +01:00
..
2026-10-25 02:45:23 +01:00
2026-10-25 03:02:57 +01:00
2026-10-23 11:02:10 +02:00
2026-05-10 10:34:32 +02:00
2026-10-22 10:14:03 +02:00
2026-10-24 12:14:33 +02:00
2026-10-21 00:03:08 +02:00
2026-10-06 18:39:50 +02:00
2026-05-09 20:46:20 +02:00
2026-09-25 07:39:06 +02:00
2026-09-25 08:51:00 +02:00
2026-09-26 01:02:48 +02:00
2026-10-08 07:56:59 +02:00
2026-06-19 22:20:31 +02:00
2026-05-10 11:05:40 +02:00
2026-07-29 13:42:04 +02:00
2026-10-15 22:31:51 +02:00
2026-09-24 07:54:59 +02:00
2026-10-16 17:11:04 +02:00
2026-10-25 00:33:18 +02:00
2026-10-21 19:24:21 +02:00
2026-10-06 21:02:41 +02:00
2026-09-24 09:19:43 +02:00
2026-10-06 21:02:41 +02:00
2026-10-21 19:24:21 +02:00
2026-10-21 15:07:06 +02:00
2026-10-15 23:05:32 +02:00
2026-10-20 22:48:24 +02:00
2026-10-20 09:08:40 +02:00
2026-08-30 14:40:43 +02:00
2026-07-04 14:46:19 +02:00
2026-10-24 11:13:25 +02:00
2026-10-20 09:08:40 +02:00
2026-08-06 14:10:28 +02:00
2026-09-10 00:37:15 +02:00
2026-10-22 23:15:43 +02:00
2026-07-16 08:48:41 +02:00
2026-10-21 16:25:25 +02:00
2026-07-21 13:08:28 +02:00
2026-09-25 02:05:19 +02:00
2026-09-26 20:11:45 +02:00
2026-10-23 19:28:05 +02:00
2026-10-22 09:09:44 +02:00
2026-09-11 12:37:54 +02:00
2026-10-20 09:08:40 +02:00
2026-10-20 13:17:41 +02:00
2026-10-15 23:05:32 +02:00
2026-10-06 19:44:52 +02:00
2026-09-26 15:55:57 +02:00
2026-07-18 02:09:33 +02:00
2026-10-20 03:34:51 +02:00
2026-10-23 21:43:55 +02:00
2026-10-01 11:17:44 +02:00
2026-09-25 07:39:06 +02:00
2026-10-04 08:17:34 +02:00
2026-09-25 07:39:06 +02:00
2026-10-25 02:42:09 +01:00
2026-10-18 13:10:19 +02:00
2026-10-22 19:57:47 +02:00
2026-10-23 00:28:38 +02:00
2026-10-25 02:42:09 +01:00
2026-09-26 19:54:40 +02:00
2026-10-21 16:50:13 +02:00
2026-09-25 07:39:06 +02:00
2026-10-04 10:19:32 +02:00
2026-10-22 18:55:56 +02:00
2026-09-25 07:39:06 +02:00
2026-10-04 22:17:27 +02:00
2026-10-04 18:23:14 +02:00
2026-10-16 00:18:35 +02:00
2026-10-22 19:04:20 +02:00
2026-09-26 19:22:03 +02:00
2026-10-23 21:43:55 +02:00
2026-09-28 00:06:47 +02:00
2026-10-23 21:43:55 +02:00
2026-10-23 21:43:55 +02:00
2026-10-25 02:42:09 +01:00
2026-09-26 01:02:48 +02:00
2026-10-23 19:27:52 +02:00
2026-09-25 07:39:06 +02:00
2026-10-04 10:19:31 +02:00
2026-09-30 22:21:46 +02:00
2026-10-15 22:28:32 +02:00
2026-10-03 18:19:50 +02:00
2026-10-15 23:03:45 +02:00
2026-09-25 21:55:14 +02:00
2026-10-20 09:08:40 +02:00
2026-10-20 09:08:40 +02:00
2026-10-25 05:57:31 +01:00
2026-10-21 19:24:21 +02:00
2026-06-19 22:20:31 +02:00
2026-10-22 18:37:25 +02:00
2026-06-27 22:40:01 +02:00
2026-10-25 05:46:08 +01:00
2026-10-25 06:27:44 +01:00
2026-10-20 09:08:40 +02:00
2026-10-21 22:27:20 +02:00
2026-09-27 14:08:49 +02:00
2026-05-10 11:05:40 +02:00
2026-09-24 08:03:04 +02:00
2026-09-26 10:41:02 +02:00
2026-10-22 05:48:05 +02:00
2026-07-26 18:34:42 +02:00
2026-09-11 12:55:52 +02:00
2026-10-11 13:09:12 +02:00
2026-10-25 00:33:18 +02:00
2026-10-09 09:14:09 +02:00
2026-07-16 23:32:28 +02:00
2026-10-05 12:53:40 +02:00
2026-05-10 16:11:12 +02:00
2026-10-20 09:08:40 +02:00
2026-10-04 20:45:21 +02:00
2026-10-22 18:22:36 +02:00
2026-10-22 10:50:56 +02:00
2026-10-06 21:49:27 +02:00
2026-10-01 13:23:17 +02:00
2026-10-20 09:08:40 +02:00
2026-09-24 12:11:21 +02:00
2026-10-06 20:47:17 +02:00
2026-08-22 16:14:54 +02:00
2026-10-05 12:40:55 +02:00
2026-10-06 19:38:57 +02:00
2026-10-25 01:03:50 +02:00
2026-10-08 18:42:01 +02:00
2026-10-21 19:24:21 +02:00
2026-10-08 08:41:25 +02:00
2026-07-15 22:49:07 +02:00
2026-10-24 22:39:19 +02:00
2026-10-21 21:39:15 +02:00
2026-10-09 10:44:17 +02:00
2026-08-13 22:07:57 +02:00
2026-09-26 15:55:57 +02:00
2026-09-03 07:42:59 +02:00
2026-09-26 19:58:50 +02:00
2026-09-25 02:05:19 +02:00
2026-10-15 23:16:11 +02:00
2026-09-26 16:23:14 +02:00
2026-09-24 08:11:14 +02:00
2026-10-04 08:17:34 +02:00
2026-10-01 08:50:31 +02:00
2026-09-10 12:23:59 +02:00
2026-08-08 01:02:08 +02:00
2026-09-24 12:30:39 +02:00
2026-10-04 20:00:18 +02:00
2026-09-24 12:37:51 +02:00
2026-10-09 17:42:00 +02:00
2026-09-09 23:03:38 +02:00
2026-10-22 10:23:14 +02:00
2026-10-09 16:16:42 +02:00
2026-09-25 13:48:31 +02:00
2026-10-22 07:18:57 +02:00
2026-10-20 09:08:40 +02:00
2026-10-16 05:28:51 +02:00
2026-10-04 11:33:42 +02:00
2026-10-21 16:25:26 +02:00
2026-10-04 22:14:14 +02:00
2026-08-03 09:52:02 +02:00
2026-09-11 12:22:47 +02:00
2026-10-24 13:07:46 +02:00
2026-10-24 18:28:19 +02:00
2026-10-24 13:11:07 +02:00
2026-09-30 23:01:57 +02:00
2026-07-17 14:29:07 +02:00
2026-10-09 01:03:02 +02:00
2026-09-27 21:20:24 +02:00
2026-10-05 12:40:55 +02:00
2026-10-01 08:56:19 +02:00
2026-10-24 12:14:33 +02:00
2026-10-16 05:49:51 +02:00
2026-10-20 09:08:40 +02:00
2026-10-08 13:03:37 +02:00
2026-09-26 22:11:27 +02:00
2026-10-08 13:03:37 +02:00
2026-10-20 09:08:40 +02:00
2026-10-25 02:52:10 +01:00
2026-10-24 20:55:19 +02:00
2026-10-04 15:56:56 +02:00
2026-07-08 22:05:05 +02:00
2026-09-26 00:38:26 +02:00
2026-10-24 20:51:35 +02:00
2026-10-04 21:59:22 +02:00
2026-09-25 07:25:29 +02:00
2026-07-21 13:08:28 +02:00
2026-10-16 03:57:46 +02:00
2026-10-01 21:53:37 +02:00
2026-08-01 19:26:47 +02:00
2026-08-10 05:32:58 +02:00
2026-10-21 12:36:15 +02:00
2026-09-27 13:07:10 +02:00
2026-08-08 15:06:10 +02:00
2026-10-21 16:50:14 +02:00
2026-10-04 10:19:31 +02:00
2026-08-08 15:54:19 +02:00
2026-09-26 01:49:02 +02:00
2026-10-22 10:14:03 +02:00
2026-09-26 01:49:02 +02:00
2026-10-05 13:07:22 +02:00
2026-10-16 02:59:48 +02:00
2026-10-15 21:48:57 +02:00
2026-10-15 21:48:57 +02:00
2026-10-08 10:02:39 +02:00
2026-10-22 23:15:43 +02:00
2026-09-26 19:54:38 +02:00
2026-10-22 18:59:07 +02:00
2026-10-04 11:33:45 +02:00
2026-10-21 21:56:16 +02:00
2026-06-22 09:00:39 +02:00
2026-06-22 09:00:39 +02:00
2026-10-21 12:46:14 +02:00
2026-10-09 12:02:25 +02:00
2026-10-09 12:02:25 +02:00
2026-10-09 12:02:25 +02:00
2026-10-22 01:19:01 +02:00
2026-07-19 13:40:03 +02:00
2026-10-20 20:26:30 +02:00
2026-10-25 02:00:57 +01:00
2026-10-23 13:30:10 +02:00
2026-10-20 06:06:24 +02:00
2026-10-23 13:30:10 +02:00
2026-10-23 13:30:10 +02:00
2026-10-10 12:59:25 +02:00
2026-10-15 12:23:09 +02:00
2026-10-23 13:30:10 +02:00
2026-10-04 11:33:45 +02:00
2026-08-07 06:11:36 +02:00
2026-10-23 12:36:09 +02:00
2026-10-16 01:34:17 +02:00
2026-09-24 10:52:04 +02:00
2026-08-12 22:52:03 +02:00
2026-09-25 07:39:06 +02:00
2026-08-07 14:16:17 +02:00
2026-10-22 10:34:45 +02:00
2026-10-22 10:34:45 +02:00
2026-10-20 10:52:54 +02:00
2026-10-16 00:18:35 +02:00
2026-10-21 16:50:13 +02:00
2026-10-08 09:37:04 +02:00
2026-10-04 10:14:22 +02:00
2026-08-06 01:29:07 +02:00
2026-05-09 18:08:11 +02:00
2026-10-20 13:07:24 +02:00
2026-09-24 09:03:58 +02:00
2026-10-20 03:41:54 +02:00
2026-10-20 09:08:40 +02:00
2026-10-20 09:08:40 +02:00
2026-10-21 19:24:21 +02:00
2026-10-20 09:47:20 +02:00
2026-10-24 21:08:45 +02:00
2026-09-24 19:40:27 +02:00
2026-10-24 22:20:06 +02:00
2026-06-19 22:20:31 +02:00
2026-10-20 13:01:45 +02:00
2026-10-25 03:19:54 +01:00
2026-07-27 14:35:34 +02:00
2026-10-20 10:03:30 +02:00
2026-10-20 10:03:30 +02:00
2026-10-15 16:42:41 +02:00
2026-07-26 18:02:35 +02:00
2026-10-08 09:05:54 +02:00
2026-07-29 15:59:27 +02:00
2026-10-23 22:41:36 +02:00
2026-10-23 22:41:36 +02:00
2026-10-23 22:41:36 +02:00
2026-10-03 18:53:28 +02:00
2026-10-16 11:00:27 +02:00
2026-10-11 20:28:00 +02:00
2026-10-14 19:18:49 +02:00
2026-10-15 15:03:06 +02:00
2026-10-14 19:15:33 +02:00
2026-10-22 05:38:36 +02:00
2026-09-27 13:21:18 +02:00
2026-10-20 03:35:03 +02:00
2026-10-16 05:45:06 +02:00
2026-09-24 09:39:27 +02:00
2026-09-10 04:01:14 +02:00
2026-10-20 13:01:45 +02:00
2026-10-15 22:05:06 +02:00
2026-09-10 01:09:50 +02:00
2026-08-06 02:36:08 +02:00
2026-10-15 23:18:24 +02:00
2026-10-17 09:17:03 +02:00
2026-10-15 23:38:39 +02:00
2026-10-23 11:02:10 +02:00
2026-10-21 21:18:33 +02:00
2026-10-17 09:56:30 +02:00
2026-10-20 09:48:15 +02:00
2026-09-09 20:06:48 +02:00
2026-09-10 04:41:38 +02:00
2026-10-08 09:28:56 +02:00
2026-10-04 22:14:14 +02:00
2026-07-29 15:59:12 +02:00
2026-10-16 05:48:00 +02:00
2026-09-26 13:29:36 +02:00
2026-09-28 00:06:47 +02:00
2026-10-20 10:45:14 +02:00
2026-07-25 15:03:44 +02:00
2026-10-20 20:13:13 +02:00
2026-10-20 09:08:40 +02:00
2026-10-08 07:56:59 +02:00
2026-10-20 09:08:40 +02:00
2026-05-31 14:36:17 +02:00
2026-10-21 20:42:06 +02:00
2026-10-21 21:43:14 +02:00
2026-10-20 09:45:19 +02:00
2026-10-20 04:22:53 +02:00
2026-08-06 20:56:16 +02:00
2026-09-25 08:04:30 +02:00
2026-10-20 09:28:40 +02:00
2026-07-26 00:45:08 +02:00
2026-10-24 22:20:06 +02:00
2026-10-20 13:01:45 +02:00
2026-10-25 00:37:35 +02:00
2026-10-03 23:36:08 +02:00
2026-10-03 22:52:05 +02:00
2026-10-20 13:01:45 +02:00
2026-10-15 16:38:12 +02:00
2026-10-20 13:01:45 +02:00
2026-08-06 02:00:35 +02:00
2026-09-25 10:31:22 +02:00
2026-08-10 07:58:48 +02:00
2026-10-04 08:17:34 +02:00
2026-10-23 21:54:25 +02:00
2026-10-20 13:01:45 +02:00
2026-10-20 09:08:40 +02:00
2026-06-19 22:20:31 +02:00
2026-09-10 07:40:05 +02:00
2026-07-25 18:41:40 +02:00
2026-10-23 08:14:32 +02:00
2026-09-26 15:21:42 +02:00
2026-10-25 02:42:09 +01:00
2026-10-22 07:18:56 +02:00
2026-10-20 12:48:17 +02:00
2026-10-21 21:40:06 +02:00
2026-10-22 05:30:00 +02:00
2026-08-08 01:03:05 +02:00
2026-09-25 07:39:06 +02:00
2026-10-21 00:03:08 +02:00
2026-08-08 09:58:50 +02:00
2026-10-22 21:23:19 +02:00
2026-10-01 10:01:06 +02:00
2026-06-05 03:45:04 +02:00
2026-06-27 19:33:10 +02:00
2026-06-19 22:20:31 +02:00
2026-10-16 00:22:23 +02:00
2026-10-16 05:48:00 +02:00
2026-07-28 14:01:11 +02:00
2026-08-08 03:03:38 +02:00
2026-10-05 12:40:55 +02:00
2026-10-14 18:57:06 +02:00
2026-08-06 13:47:42 +02:00
2026-10-21 12:01:53 +02:00
2026-09-11 13:43:19 +02:00
2026-07-30 23:30:28 +02:00
2026-10-21 21:40:06 +02:00
2026-09-25 02:05:19 +02:00
2026-09-26 20:18:55 +02:00
2026-09-26 22:08:51 +02:00
2026-10-15 22:55:03 +02:00
2026-10-20 09:08:40 +02:00
2026-10-22 01:15:01 +02:00
2026-09-10 05:07:15 +02:00
2026-10-21 19:53:57 +02:00
2026-10-23 12:57:47 +02:00
2026-10-19 10:53:59 +02:00
2026-10-15 15:10:18 +02:00
2026-10-14 19:08:22 +02:00
2026-07-25 11:36:18 +02:00
2026-10-20 09:08:40 +02:00
2026-10-25 02:14:17 +01:00
2026-10-15 15:12:57 +02:00
2026-10-25 06:27:44 +01:00
2026-09-25 02:05:19 +02:00
2026-10-20 09:08:40 +02:00
2026-10-20 16:01:13 +02:00
2026-08-09 06:53:57 +02:00
2026-10-15 21:48:57 +02:00
2026-10-21 12:36:15 +02:00
2026-10-23 13:12:23 +02:00
2026-10-24 23:16:24 +02:00
2026-10-23 12:57:47 +02:00
2026-10-04 11:37:57 +02:00
2026-10-23 14:35:01 +02:00
2026-10-04 11:22:17 +02:00
2026-10-04 10:41:08 +02:00
2026-10-04 14:55:03 +02:00
2026-10-04 11:22:17 +02:00
2026-10-25 00:33:55 +02:00
2026-10-22 05:38:45 +02:00
2026-10-23 12:36:09 +02:00
2026-07-19 02:31:45 +02:00
2026-10-11 13:09:12 +02:00
2026-09-09 22:55:53 +02:00
2026-09-26 19:54:38 +02:00
2026-10-22 00:39:59 +02:00
2026-10-11 13:56:24 +02:00
2026-08-06 17:52:10 +02:00
2026-08-06 19:33:15 +02:00
2026-08-06 18:21:40 +02:00
2026-09-10 15:35:52 +02:00
2026-10-15 15:06:02 +02:00
2026-09-06 15:36:35 +02:00
2026-09-26 20:06:36 +02:00
2026-10-16 05:25:50 +02:00
2026-10-16 00:25:04 +02:00
2026-10-24 12:14:33 +02:00
2026-10-24 12:14:33 +02:00
2026-10-24 12:14:33 +02:00
2026-10-20 09:08:40 +02:00
2026-10-14 18:57:01 +02:00
2026-10-23 21:43:55 +02:00
2026-10-23 21:43:55 +02:00
2026-10-20 16:06:10 +02:00
2026-10-22 05:30:00 +02:00
2026-10-04 15:29:02 +02:00
2026-10-21 00:06:21 +02:00
2026-09-26 16:56:02 +02:00
2026-10-20 09:08:40 +02:00
2026-10-09 16:45:39 +02:00
2026-09-26 20:06:36 +02:00
2026-10-04 14:14:22 +02:00
2026-10-22 09:09:44 +02:00
2026-07-23 15:16:48 +02:00
2026-10-20 10:56:55 +02:00
2026-09-26 22:34:21 +02:00
2026-10-20 09:08:40 +02:00
2026-10-08 07:56:59 +02:00
2026-09-02 11:51:09 +02:00
2026-10-25 00:44:15 +02:00
2026-10-25 00:44:15 +02:00
2026-10-22 05:30:00 +02:00
2026-07-07 22:00:14 +02:00
2026-09-09 20:06:48 +02:00
2026-10-20 11:00:25 +02:00
2026-10-14 20:09:14 +02:00
2026-10-20 13:01:45 +02:00
2026-10-21 19:24:21 +02:00
2026-08-07 06:11:36 +02:00
2026-08-07 06:11:36 +02:00
2026-10-20 09:48:15 +02:00
2026-10-25 00:26:55 +02:00
2026-10-15 22:49:00 +02:00
2026-10-15 22:05:06 +02:00
2026-10-23 11:02:10 +02:00
2026-08-07 14:30:10 +02:00
2026-10-20 09:28:40 +02:00
2026-07-26 14:04:44 +02:00
2026-10-20 16:01:13 +02:00
2026-06-04 10:05:47 +02:00
2026-10-24 12:14:33 +02:00
2026-10-20 09:08:40 +02:00
2026-10-24 12:14:33 +02:00
2026-10-08 22:57:47 +02:00
2026-10-24 23:06:00 +02:00
2026-07-15 22:49:07 +02:00
2026-09-26 20:06:36 +02:00
2026-09-26 01:02:48 +02:00
2026-10-23 13:30:10 +02:00
2026-10-15 22:49:00 +02:00
2026-10-20 13:01:45 +02:00
2026-09-10 10:49:12 +02:00
2026-10-20 13:29:14 +02:00
2026-10-08 08:41:25 +02:00
2026-10-25 00:35:10 +02:00
2026-09-27 13:46:38 +02:00
2026-08-02 02:00:08 +02:00
2026-10-08 09:06:09 +02:00
2026-10-09 12:02:25 +02:00
2026-10-09 14:11:46 +02:00
2026-10-20 09:08:40 +02:00
2026-10-23 19:27:52 +02:00
2026-10-08 08:41:25 +02:00
2026-06-19 22:20:31 +02:00
2026-08-08 21:01:25 +02:00
2026-08-08 14:36:08 +02:00
2026-09-10 11:11:38 +02:00
2026-10-08 22:37:57 +02:00
2026-08-08 23:00:39 +02:00
2026-09-24 09:44:51 +02:00
2026-10-15 22:11:50 +02:00
2026-10-15 22:11:50 +02:00
2026-09-26 20:22:12 +02:00
2026-06-05 08:10:13 +02:00
2026-07-22 04:14:15 +02:00
2026-10-16 02:59:47 +02:00
2026-10-21 16:25:26 +02:00
2026-10-14 19:08:22 +02:00
2026-10-21 00:05:22 +02:00
2026-10-20 09:08:40 +02:00
2026-10-20 09:08:40 +02:00
2026-10-21 12:59:43 +02:00
2026-10-20 20:13:13 +02:00
2026-10-22 05:30:00 +02:00
2026-10-22 01:15:01 +02:00
2026-08-08 09:53:09 +02:00
2026-10-20 04:37:39 +02:00
2026-09-27 15:11:43 +02:00
2026-10-03 17:53:36 +02:00
2026-10-03 23:26:48 +02:00
2026-10-21 20:51:13 +02:00
2026-10-20 16:09:28 +02:00