mirror of
https://github.com/MeshCore-Beacon/beacon-server.git
synced 2026-12-06 16:44:20 +00:00
* feat(db): drop six lookup-table indexes that no plan reads * feat(db): drop known_routes.last_reconfirmed_at, which nothing reads * feat(metrics): report how much of each database sequence is used * refactor(db): retire the legacy API pool; slow region and message statements get their own two connections * feat(config): database.slow_pool_size sizes the slow pool * refactor(db): route the two former read-model fallbacks to the slow pool * fix(metrics): sequence headroom reads any schema name and marks cycling sequences * feat(metrics): count the 503s pages answer, by reason and model; warn about a busy slow pool once a minute * refactor(db): expose the adverts page mapping and the original channel message pages for oracles * refactor(db): name the read-model fallbacks the slow pool runs; count only what this tree refuses * feat(config): the slow pool defaults to 8 connections while it also serves untrusted read-model pages
25 lines
1.2 KiB
SQL
25 lines
1.2 KiB
SQL
-- name: GetRouteEvidenceRoute :one
|
|
SELECT id, path_key, node_ids, hash_prefix, iata, hop_count, first_seen, last_seen, observation_count
|
|
FROM known_routes
|
|
WHERE iata = @iata::bpchar AND path_key = @path_key::bytea;
|
|
|
|
-- name: ListRouteEvidence :many
|
|
-- Leading index equalities and the time/ID boundary bound both custom and generic plans.
|
|
-- Full-byte equality is required even when the compact digest matches. TRACE path bytes
|
|
-- carry readings; unclassified legacy observations cannot be safely called ordinary paths.
|
|
SELECT po.id, po.packet_hash, po.observer_id, o.display_name AS observer_name,
|
|
po.heard_at, po.payload_type, po.rssi, po.snr
|
|
FROM packet_observations po
|
|
JOIN observers o ON o.id = po.observer_id
|
|
WHERE po.iata = @iata::bpchar
|
|
AND po.hash_size = @hash_size::smallint
|
|
AND decode(md5(po.path_bytes), 'hex') = @path_digest::bytea
|
|
AND po.path_bytes = @path_bytes::bytea
|
|
AND po.hop_count >= 2
|
|
AND po.hop_count = @hop_count::smallint
|
|
AND po.path_bytes IS NOT NULL AND po.payload_type IS NOT NULL AND po.payload_type <> 9
|
|
AND po.heard_at >= @since::timestamptz AND po.heard_at < @until::timestamptz
|
|
AND (po.heard_at, po.id) < (@before_at::timestamptz, @before_id::bigint)
|
|
ORDER BY po.heard_at DESC, po.id DESC
|
|
LIMIT @page_limit::integer;
|