Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uS7OX-003ayL-AO for pgsql-general@arkaria.postgresql.org; Thu, 19 Jun 2025 05:01:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uS7OV-007eZE-7I for pgsql-general@arkaria.postgresql.org; Thu, 19 Jun 2025 05:00:59 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uS7OU-007eZ6-Rp for pgsql-general@lists.postgresql.org; Thu, 19 Jun 2025 05:00:59 +0000 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uS7OT-002oJK-1N for pgsql-general@lists.postgresql.org; Thu, 19 Jun 2025 05:00:58 +0000 Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-60867565fb5so511464a12.3 for ; Wed, 18 Jun 2025 22:00:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1750309256; x=1750914056; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=r7DLX5UCS/D4w3fGxicJq4UrzrHHUT/tQoI021w+6MU=; b=eOZNgD1+yEYUo47JoKXbzFekF2qZxxJL6JD7/xB8TZvj9ijanFbBA+VWzxviDCnY7x 3fP+8L/LcNKujJAnLknnw5WZON31hMeUbd1aC70YxZv2gbdo1fdM4J36V2y925bGKy55 esaMUpwSTWqf4+VY1tNTlEAkBP0zge8NWiPHnblXeTOe5j0ta1Z+D07XGKQPYNxugYN8 SpmmN9v9XBOXLohaNyL+JDDHLYcdZwmfwtWLL98yKvLyPdso/aI/N6NszD/UcZgA6hgm r61ULCokiEN1JpxHD3JhQRzdwhMl8ux7OpGKVl2f284Ewou35QqysOPZZXJkC7QkFHQc Ww4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750309256; x=1750914056; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=r7DLX5UCS/D4w3fGxicJq4UrzrHHUT/tQoI021w+6MU=; b=M4wn89xLOrdh4rVEn60fk3uydFoVsVz7jGK3aKxSqKh6KbG8felyL5DHhJYVgYD7Oz XVQwogPjHRdgh0FZBmKlbXKsVjBuj5xz4uuqytSw3X3oP7V8eA4+1tcwPgFfO0hANWgT sxtxCc1nj7mzH4g4wH1UrlyU1f19JD29f2fDRK/rRzwPL3LDZUw/262Wl67D6yMFSMww e8+UI9OIbo+E2Hz6df3NZQv3gMQp/HE6ABM5CIaE11zD1EE/F4sl5EmrIffMu9qc8BHF zq1uXRNSZ45B/v1PHJz6997gc/nMgq7pgtx0GzNZy+bq7uc2RMK7w5GUrqGnG3kTZtNR nVnA== X-Forwarded-Encrypted: i=1; AJvYcCWtBAiRE3QeONhFwFJSBCwgHAHrUuji7lyq3PGRCtgkDtDq2F+53XqC+CqwinfckGKNxVfJFFUq09d0YOjK@lists.postgresql.org X-Gm-Message-State: AOJu0Yyi2Jqd1Q6PAUw+4YN0qKPf1fmoDtL8oFTlfhJFS4aKF0itP94l 1+ahLhisf9Esu0fJSI9ou60hfNmwCdpUbJt66HxLTr3BsyezU/X+HWXXeZj/p1FGQcOzPZbzy5Q NMUJH5ew= X-Gm-Gg: ASbGnctaIxQxA44TOtTysy8mLq0fp/RFCReW64WUUpaA4358XkH0IQaHv5dU4xQeuCA kV88GcqG2fFZAUSIJlcIrm7SSfKjn0I/alvhioquvMYOjkewQUO5dUbuVb4z1AR92hQwhwd7e2Q 7OjtSr0thCHtqhhhJnTzWhKS0zjXEGXJa/uQZdDwoMIzv4uMSuhS/K8hvoUs13xL7AfaOvLnk07 FBn8vz0eXhmQAP5/mM7y2Vq3KSf3VNZOCAB8JYo/8Skcx43Vbmi6EmgLdMEvSXI5g+Erdzcd2Fk 6krA27/s4WiqGQcwWfrYmV4fxEGSZtS66sXRrDc6tRHa7oEwXjfna2zM/pM5GDrz6IWJqHdxfgI DKt+7PiLpLU2/XIVr X-Google-Smtp-Source: AGHT+IHivUgA8kyflButZOfwOvs6xCeCRtHPbOfDkENjhmDCcc+YDoHDy9wY7IEX0/kFD96ZaBwkvA== X-Received: by 2002:a05:6402:51cd:b0:608:48fc:ff73 with SMTP id 4fb4d7f45d1cf-608d09bb709mr17491677a12.26.1750309255145; Wed, 18 Jun 2025 22:00:55 -0700 (PDT) Received: from laurenz.albe-K4N0CV00F97414D ([2001:871:255:52d3:3ac8:61ab:b634:342]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-608b48cd687sm10650526a12.18.2025.06.18.22.00.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jun 2025 22:00:54 -0700 (PDT) Message-ID: <50b51d926417c0832e24753903710d0fa3311815.camel@cybertec.at> Subject: Re: Postgres DB design Question (High Level) From: Laurenz Albe To: Al Grant , pgsql-general@lists.postgresql.org Date: Thu, 19 Jun 2025 07:00:54 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2 (3.56.2-1.fc42) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, 2025-06-19 at 16:50 +1200, Al Grant wrote: > I want to create a web based dashboard for all the currently detected > signals, where the dashboard contains a graph of the daily beep rate > for each channel (max 100 channels) over user selectable periods from > 1 week to 1 year - that query does not scale well if I query the bpm > table. >=20 > To avoid this I have created a bpm summary table which is generated > periodically (hourly) off the bpm table. The bpm summary table > contains the dominant beep rate for a given hour (so 2 records per day > per channel assuming a signal is detected). >=20 > Does this summary table approach make sense? Yes. Pre-aggregation to reduce the data volume is common in a data warehouse. Ideally, you don't have to scan the entire base table to create the summary. You can consider a trigger for that, but more elegant might be a solution based on partitioning, where you aggregate a partition once it is complete. > I have noted that I am periodically syncing from MySQL to the server, > and then periodically updating the summary table - its multi stage > syncing and I wonder if that makes this approach fragile (although I > don't see any alternative). "MySQL" and "fragile" in the same sentence. Sounds about right. Yours, Laurenz Albe