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 1qx8uf-00GJVc-9v for pgsql-general@arkaria.postgresql.org; Sun, 29 Oct 2023 16:45:21 +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 1qx8ud-008Tbl-VT for pgsql-general@arkaria.postgresql.org; Sun, 29 Oct 2023 16:45:19 +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 1qx8ud-008Tbc-8u for pgsql-general@lists.postgresql.org; Sun, 29 Oct 2023 16:45:19 +0000 Received: from rs6162.luxsci.com ([162.142.76.255]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qx8uW-002uuV-D2 for pgsql-general@lists.postgresql.org; Sun, 29 Oct 2023 16:45:15 +0000 Received: from pfortin.com (h199.241.136.40.dynamic.ip.windstream.net [40.136.241.199]) (authenticated bits=0) by rs6162.luxsci.com (8.15.2/8.14.9) with ESMTPSA id 39TGj82M2273556 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT) for ; Sun, 29 Oct 2023 16:45:09 GMT Date: Sun, 29 Oct 2023 12:45:08 -0400 From: pf@pfortin.com To: pgsql-general@lists.postgresql.org Subject: Re: [SOLVED?] Re: Disk wait problem... not hardware... Message-ID: <20231029124508.71a8ce22.pfortin@pfortin.com> In-Reply-To: <20231029151605.kijo6gumeen7jj26@hjp.at> References: <20231023175529.59f309bb@pfortin.com> <9938ff1a-8837-454b-a50c-a748e84c172a@aklaver.com> <20231026095000.4swq6vbgdsw3palp@hjp.at> <20231026155016.6b739a7e.pfortin@pfortin.com> <20231026220325.2204a3f6.pfortin@pfortin.com> <20231027170711.xgz3xrf7cujx7udh@hjp.at> <20231027194609.1bf96324.pfortin@pfortin.com> <20231029092146.53351f7e@pfortin.com> <20231029151605.kijo6gumeen7jj26@hjp.at> X-Mailer: Claws Mail 4.1.1git67 (GTK 3.24.38; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Lux-Comment: Message 39TGj82M2273556 sent by user #22427 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pfortin.com; h=date:from:to:subject:message-id:in-reply-to:references:mime-version:content-type:content-transfer-encoding; s=dkim; bh=jth5kCZc+tM9k8Y017cAd6zzUXtQPVNKvJNBCQnSJ5o=; b=E2dCAKcPiUBNU84I29PC/Rx2feZXMaRiRa95p2hVbgcXu1rfpJj2amG2uLtXQUvUQo7Nu4R3I80lQENLMraJQGcurw7IHcRnH21hQr/XG2Kw9plPgKKMi5GhaDgHAt/L8JMrbMMHrl8rUrVeqcf0Xz4vN20TNoPRsvwZYg/DIAM= List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sun, 29 Oct 2023 16:16:05 +0100 Peter J. Holzer wrote: >On 2023-10-29 09:21:46 -0400, pf@pfortin.com wrote: >> These are all static tables. Does PG maintain a table row count so as to >> avoid having to count each time? =20 > >No. To count the rows in a table, Postgres has to actually read the >whole table (or an index, if a suitable index (e.g. a primary key) >exists). Am I correct to assume count(fieldname) would only load that column for counting? In other words: we should be specific (avoid "*") in general? >However, the table statistics contain an estimate for the number of >rows: > >hjp=3D> select schemaname, relname, n_live_tup from pg_stat_user_tables or= der by 3 desc; =20 >=E2=95=94=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90= =E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=A4=E2=95=90=E2=95=90=E2= =95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95= =90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90= =E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2= =95=A4=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95= =90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=97 >=E2=95=91 schemaname =E2=94=82 relname =E2=94=82 n_live_= tup =E2=95=91 >=E2=95=9F=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=BC=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=BC=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=95=A2 >=E2=95=91 public =E2=94=82 ncvhis_2016_12_03 =E2=94=82 9999= 977 =E2=95=91 >=E2=95=91 public =E2=94=82 random_test =E2=94=82 1000= 000 =E2=95=91 >=E2=95=91 public =E2=94=82 beislindex =E2=94=82 = 351 =E2=95=91 >=E2=95=91 public =E2=94=82 delivery =E2=94=82 = 6 =E2=95=91 >... Are there prerequisites for this query? Every (264) n_live_tup returned was zero... though, VERY fast.. :) >This is an estimate, not the actual count, so it might be wrong >(sometimes very wrong), but accessing it is fast and it might be good >enough for your purposes. Thanks for sharing... We're learning fast... :) >> WB is setup to: >> * autoload table row count >> * autoload table data (restricted with LIMIT) =20 > >Maybe WB can be set up to get n_live_tup instead of the real row count? It appears this is hard-coded [on/off only]; but I thought I saw the WB author post on this list recently... > hp >