Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mXRfL-0001l5-6z for pgsql-general@arkaria.postgresql.org; Mon, 04 Oct 2021 17:22:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mXRfK-0007aa-6S for pgsql-general@arkaria.postgresql.org; Mon, 04 Oct 2021 17:22:14 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mXRfJ-0007aR-Q1 for pgsql-general@lists.postgresql.org; Mon, 04 Oct 2021 17:22:13 +0000 Received: from mail-il1-x135.google.com ([2607:f8b0:4864:20::135]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mXRfH-0001Gr-NF for pgsql-general@postgresql.org; Mon, 04 Oct 2021 17:22:13 +0000 Received: by mail-il1-x135.google.com with SMTP id d11so19060033ilc.8 for ; Mon, 04 Oct 2021 10:22:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=AL0j4ap7V4CI8HBLS4B4hZNnzGT9/p1sJKsEZNgZyO8=; b=OndAjUhX4piYgLKs3u16T/ePUlzE7aYgf5+0jxN1Fl/Q+VobTDNmmFMLTTQUOLZfxx 9nOkUxba4ox/Jj7RPlziXRWMLTn9YI66wXIoJHeceFO/6xemT6hRk3ttrdgQasfASjfv O066Cz2p4KXt3co1zW5e7IW5PQUOQQrTI15VOa5LJBaO7O051hfi3Sx6DwsbtEJFGCeJ dYYRwNINRWHkB7QSIVBs8pNqKytuEtKy4X/UKHU1QwV5dvc1psjDO30gNDlUoatFaUvY C+A5eMItxj7R8jKCdH67R1tSDHmxsPXKHJBfrAzJt4jR7xBAYTGA2qnih6sPI0o/6dpk L8Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=AL0j4ap7V4CI8HBLS4B4hZNnzGT9/p1sJKsEZNgZyO8=; b=NbQ8LHN30fckr+jRigS4OOJmXCQn1DyZQtnV2pPQWHhkQOjPJv/NsgWa/hw3ywVQvZ I9QtN07WfHs9RMrZQa8UHj4eo6Jor1n6gIkEVB7pr7rtcp+2Wy+wZLWzkViyD36fYxqF 1+v5NkacNcvDrMuI0sHr+PvBu9Ixdx/x4zp5GnoFre6s/gXuiNysRzj1oOy36tf5zGHO mNKXK2d9FLj65Rzg+RaF3WQIyve9uc8BAMFWElk7dL3ijvIFbKb8i53kQobBDqShS3oa 3KhyZlr1ZkF4MEQBjxl7sI94Znvhr6onsmqqEcfqEkZ+VaTGVDuToDOZFd7fgyqIIuMk qGUA== X-Gm-Message-State: AOAM531c4lNKgfcF/IfW6478vQFGIrEqk6vSb6zQAOyp+NSb+sW3VZQ1 GoxIXSOAohDz9c92JcDTaZ62b96TAoQ= X-Google-Smtp-Source: ABdhPJz0ucKIwJ+8FwHhvJ4xzQBP45uw84thhqt6k+KsHrbQSY8pH+Rt14KfHADjToDjzyjK36y2ow== X-Received: by 2002:a05:6e02:1003:: with SMTP id n3mr10474013ilj.279.1633368129812; Mon, 04 Oct 2021 10:22:09 -0700 (PDT) Received: from [10.0.0.94] (c-73-63-59-118.hsd1.ut.comcast.net. [73.63.59.118]) by smtp.gmail.com with ESMTPSA id f13sm9475080ioz.48.2021.10.04.10.22.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 04 Oct 2021 10:22:09 -0700 (PDT) Subject: Re: Growth planning To: Israel Brewster Cc: "pgsql-general@postgresql.org" References: <35170FC5-0A05-48F3-9ED1-F007CC1AF365@alaska.edu> <39A75BC4-7F4D-45F9-BD66-891F0294A072@gmail.com> From: Rob Sargent Message-ID: <8583b994-130a-71a9-c4a6-73cf953ac7f6@gmail.com> Date: Mon, 4 Oct 2021 11:22:08 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------02BBCF6C32851D5B25ACC7D1" Content-Language: en-CA List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------02BBCF6C32851D5B25ACC7D1 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 10/4/21 11:09 AM, Israel Brewster wrote: >> On Oct 4, 2021, at 8:46 AM, Rob Sargent > > wrote: >> >>> On Oct 4, 2021, at 10:22 AM, Israel Brewster >> > wrote: >> Guessing the “sd” is "standard deviation”?  Any chance those stddevs >> are easily calculable from base data?  Could cut your table size in >> half (and put those 20 cores to work on the reporting). > > Possible - I’d have to dig into that with the script author. I was > just handed an R script (I don’t work with R…) and told here’s the > data it needs, here’s the output we need stored in the DB. I then > spent just enough time with the script to figure out how to hook up > the I/O. The schema is pretty much just a raw dump of the output - I > haven’t really spent any resources figuring out what, exactly, the > data is. Maybe I should :-) > >>  And I wonder if the last three indices are strictly necessary? They >> take disc space too. > > Not sure. Here’s the output from pg_stat_all_indexes: > > volcano_seismology=# select * from pg_stat_all_indexes where > relname='data'; >  relid | indexrelid | schemaname | relname |   indexrelname        | > idx_scan | idx_tup_read | idx_tup_fetch > -------+------------+------------+---------+---------------------------+----------+--------------+--------------- >  19847 |      19869 | public     | data    | data_pkey           |    >     0 |            0 |             0 >  19847 |      19873 | public     | data    | > date_station_channel_idx  |   811884 |  12031143199 |   1192412952 >  19847 |      19875 | public     | data    | station_channel_epoch_idx > |        8 |       318506 |   318044 >  19847 |      19876 | public     | data    | station_data_idx        >   |     9072 |         9734 |   1235 >  19847 |      19877 | public     | data    | station_date_idx        >   |   721616 |  10927533403 |   10908912092 >  19847 |      20479 | public     | data    | > data_station_channel_idx  |    47293 | 194422257262 |   6338753379 > (6 rows) > > so they *have* been used (although not the station_data_idx so much), > but this doesn’t tell me when it was last used, so some of those may > be queries I was experimenting with to see what was fastest, but are > no longer in use. Maybe I should keep an eye on this for a while, see > which values are increasing. > >> >> But my bet is you’re headed for partitioning on datetime or perhaps >> station. > > While datetime partitioning seems to be the most common, I’m not clear > on how that would help here, as the most intensive queries need *all* > the datetimes for a given station, and even the smaller queries would > be getting an arbitrary time range potentially spanning several, if > not all, partitions. Now portioning on station seems to make sense - > there are over 100 of those, and pretty much any query will only deal > with a single station at a time. Perhaps if more partitioning would be > better, portion by both station and channel? The queries that need to > be fastest will only be looking at a single channel of a single station. > > I’ll look into this a bit more, maybe try some experimenting while I > still have *relatively* little data. My main hesitation here is that > in the brief look I’ve given partitioning so far, it looks to be a > royal pain to get set up. Any tips for making that easier? > > If no queries address multiple stations you could do a table per station.  Doesn't smell good but you have a lot of data and well, speed kills. I think the date-station-channel could "take over" for the station-date.  Naturally the latter is chosen if you give just the two fields, but I would be curious to see how well the former performs given just its first two fields(when station-date doesn't exist). --------------02BBCF6C32851D5B25ACC7D1 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit
On 10/4/21 11:09 AM, Israel Brewster wrote:
On Oct 4, 2021, at 8:46 AM, Rob Sargent <robjsargent@gmail.com> wrote:

On Oct 4, 2021, at 10:22 AM, Israel Brewster <ijbrewster@alaska.edu> wrote:
Guessing the “sd” is "standard deviation”?  Any chance those stddevs are easily calculable from base data?  Could cut your table size in half (and put those 20 cores to work on the reporting).

Possible - I’d have to dig into that with the script author. I was just handed an R script (I don’t work with R…) and told here’s the data it needs, here’s the output we need stored in the DB. I then spent just enough time with the script to figure out how to hook up the I/O. The schema is pretty much just a raw dump of the output - I haven’t really spent any resources figuring out what, exactly, the data is. Maybe I should :-)

 And I wonder if the last three indices are strictly necessary? They take disc space too.

Not sure. Here’s the output from pg_stat_all_indexes:

volcano_seismology=# select * from pg_stat_all_indexes where relname='data';
 relid | indexrelid | schemaname | relname |       indexrelname        | idx_scan | idx_tup_read | idx_tup_fetch 
-------+------------+------------+---------+---------------------------+----------+--------------+---------------
 19847 |      19869 | public     | data    | data_pkey                 |        0 |            0 |             0
 19847 |      19873 | public     | data    | date_station_channel_idx  |   811884 |  12031143199 |    1192412952
 19847 |      19875 | public     | data    | station_channel_epoch_idx |        8 |       318506 |        318044
 19847 |      19876 | public     | data    | station_data_idx          |     9072 |         9734 |          1235
 19847 |      19877 | public     | data    | station_date_idx          |   721616 |  10927533403 |   10908912092
 19847 |      20479 | public     | data    | data_station_channel_idx  |    47293 | 194422257262 |    6338753379
(6 rows)

so they *have* been used (although not the station_data_idx so much), but this doesn’t tell me when it was last used, so some of those may be queries I was experimenting with to see what was fastest, but are no longer in use. Maybe I should keep an eye on this for a while, see which values are increasing.


But my bet is you’re headed for partitioning on datetime or perhaps station.

While datetime partitioning seems to be the most common, I’m not clear on how that would help here, as the most intensive queries need *all* the datetimes for a given station, and even the smaller queries would be getting an arbitrary time range potentially spanning several, if not all, partitions. Now portioning on station seems to make sense - there are over 100 of those, and pretty much any query will only deal with a single station at a time. Perhaps if more partitioning would be better, portion by both station and channel? The queries that need to be fastest will only be looking at a single channel of a single station.

I’ll look into this a bit more, maybe try some experimenting while I still have *relatively* little data. My main hesitation here is that in the brief look I’ve given partitioning so far, it looks to be a royal pain to get set up. Any tips for making that easier?


If no queries address multiple stations you could do a table per station.  Doesn't smell good but you have a lot of data and well, speed kills.

I think the date-station-channel could "take over" for the station-date.  Naturally the latter is chosen if you give just the two fields, but I would be curious to see how well the former performs given just its first two fields(when station-date doesn't exist).

--------------02BBCF6C32851D5B25ACC7D1--