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 1smBtj-003vPX-PN for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Sep 2024 12:47:40 +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 1smBth-009gCe-93 for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Sep 2024 12:47:37 +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 1smBtg-009gCN-S2 for pgsql-hackers@lists.postgresql.org; Thu, 05 Sep 2024 12:47:37 +0000 Received: from mail-vk1-xa2c.google.com ([2607:f8b0:4864:20::a2c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1smBte-000HCC-N0 for pgsql-hackers@postgresql.org; Thu, 05 Sep 2024 12:47:36 +0000 Received: by mail-vk1-xa2c.google.com with SMTP id 71dfb90a1353d-4fcefbd6bc4so260367e0c.1 for ; Thu, 05 Sep 2024 05:47:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725540454; x=1726145254; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=xBuCN9YtbNuI60tydv7x//vdZswqsGNrPNzIJgFH84Q=; b=Ge755w7uq0DY3FhyUp9KCNkCOuz1m3GFmtkBU+z/4CKVvua+QO8dVyQuZa6grRszL1 BvhJmj0wt1v3K6qe+VuEen2+tHZsHgIkgzgzkvrJJ121k9OZNeQXHgceZR1nPSi2/LOe NQ7yqCNODxwnQoLcq4S4V6cnH/Yd0LX8IhlDXqV+HJCswsw265LUfFP+W7dMYP4YN0KY Miz3IdCoeg3VThwAE+BlqV9dkBKr4Ycx/i2qIDFmCDX3xealGpmw4X7d5yK/bFwdLtHx W0+d34HTVaCDYtWfcjqcTzOImvllRlEtDabBJGRTIkIWrcpZY8UrP+gX64/Vicbsh1F9 d1wA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725540454; x=1726145254; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xBuCN9YtbNuI60tydv7x//vdZswqsGNrPNzIJgFH84Q=; b=O2Mau3bk8GbJ9XpYF6nBmrL3GtczLj2GqGksfSJ8gAhRxVYrTinN2F40pw4tPzelqD yquof112BGS7z5K/QbB0mU5Re3ATKkC7a20YzoYoM3K1Wjwrjz9aC2lkQU0eDMFDrWXC 8emFWG2rLVWa/SbdvwGKLpdy/LQWoCm2VEsa38Jf4VPOyBTYokOK9NzdyIMpWRlWEclP U3Wz85TW4C7nW249vbKoVBlwUNu3lqr/Cto7nAeeKIct4tv9AcRNDCr8kvfSFfjqojm6 eM+QFcHQG38krd4KwIAITkoRyVC/IAbzaLR+chU6ssumRSDMG6iaTUh176d6/vKsuT3f SKCg== X-Forwarded-Encrypted: i=1; AJvYcCX2NLUZJTF4dEdeVxV8NS22e4qbAg33Ig2Saw4RfxPmiaXQmD1xtrWJPbFEsbz1cJv1E3+bwVbgkz9WF2vb@postgresql.org X-Gm-Message-State: AOJu0YzoQCCSlbstDhVRj3ItI3rlmecxWHt/I1YYLlORWhOWH5QtPyFt +Vz9/78ioqwYeH04zsXL1ptYaitgt0JgRMMP09ud7Gp3YBlMOQk/wPxFg9Iu/pPVOxmwal7o82W P1AAKWWA15nSbvLQ1KWS2AvHaEMQ= X-Google-Smtp-Source: AGHT+IG3PTfFGa7ah4S6qH0tdza7JcY1rKT2UOLBluCvIyuRkKEeMPt9kdh6bJhtQieN9wPjRFh2QVelG1hbvLmas4o= X-Received: by 2002:a05:6122:29cb:b0:4f5:254e:e111 with SMTP id 71dfb90a1353d-5009b07f31fmr18651444e0c.7.1725540453321; Thu, 05 Sep 2024 05:47:33 -0700 (PDT) MIME-Version: 1.0 References: <53c47c2d-72a5-44f2-900c-9973b2af1808@tantorlabs.com> <4a902cea-54fb-41b5-b208-b84731a5f577@postgrespro.ru> <092adec6-4eae-4bd4-bd0d-473a9df1282b@tantorlabs.com> <3deae1bd-ad84-4459-a26e-04c9136b84e9@postgrespro.ru> In-Reply-To: From: jian he Date: Thu, 5 Sep 2024 20:47:00 +0800 Message-ID: Subject: Re: Vacuum statistics To: Alena Rybakina Cc: Alexander Korotkov , Ilia Evdokimov , Andrei Zubkov , Alena Rybakina , pgsql-hackers , a.lepikhov@postgrespro.ru Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Sep 5, 2024 at 1:23=E2=80=AFAM Alena Rybakina wrote: > > Hi, all! > > I have attached the new version of the code and the diff files > (minor-vacuum.no-cbot). > hi. still have white space issue when using "git apply", you may need to use "git diff --check" to find out where. /* ---------- diff --git a/src/test/regress/expected/opr_sanity.out b/src/test/regress/expected/opr_sanity.out index 5d72b970b03..7026de157e4 100644 --- a/src/test/regress/expected/opr_sanity.out +++ b/src/test/regress/expected/opr_sanity.out @@ -32,11 +32,12 @@ WHERE p1.prolang =3D 0 OR p1.prorettype =3D 0 OR prokind NOT IN ('f', 'a', 'w', 'p') OR provolatile NOT IN ('i', 's', 'v') OR proparallel NOT IN ('s', 'r', 'u'); - oid | proname -------+------------------------ + oid | proname +------+------------------------- 8001 | pg_stat_vacuum_tables 8002 | pg_stat_vacuum_indexes -(2 rows) + 8003 | pg_stat_vacuum_database +(3 rows) looking at src/test/regress/sql/opr_sanity.sql: -- **************** pg_proc **************** -- Look for illegal values in pg_proc fields. SELECT p1.oid, p1.proname FROM pg_proc as p1 WHERE p1.prolang =3D 0 OR p1.prorettype =3D 0 OR p1.pronargs < 0 OR p1.pronargdefaults < 0 OR p1.pronargdefaults > p1.pronargs OR array_lower(p1.proargtypes, 1) !=3D 0 OR array_upper(p1.proargtypes, 1) !=3D p1.pronargs-1 OR 0::oid =3D ANY (p1.proargtypes) OR procost <=3D 0 OR CASE WHEN proretset THEN prorows <=3D 0 ELSE prorows !=3D 0 END OR prokind NOT IN ('f', 'a', 'w', 'p') OR provolatile NOT IN ('i', 's', 'v') OR proparallel NOT IN ('s', 'r', 'u'); that means oid | proname ------+------------------------- 8001 | pg_stat_vacuum_tables 8002 | pg_stat_vacuum_indexes 8003 | pg_stat_vacuum_database These above functions, pg_proc.prorows should > 0 when pg_proc.proretset is true. I think that's the opr_sanity test's intention. so you may need to change pg_proc.dat. BTW the doc says: prorows float4, Estimated number of result rows (zero if not proretset) segmentation fault cases: select * from pg_stat_vacuum_indexes(0); select * from pg_stat_vacuum_tables(0); + else if (type =3D=3D PGSTAT_EXTVAC_DB) + { + PgStatShared_Database *dbentry; + PgStat_EntryRef *entry_ref; + Oid dbid =3D PG_GETARG_OID(0); + + if (OidIsValid(dbid)) + { + entry_ref =3D pgstat_get_entry_ref_locked(PGSTAT_KIND_DATABASE, + dbid, InvalidOid, false); + dbentry =3D (PgStatShared_Database *) entry_ref->shared_stats; + + if (dbentry =3D=3D NULL) + /* Table doesn't exist or isn't a heap relation */ + return; + + tuplestore_put_for_database(dbid, rsinfo, dbentry); + pgstat_unlock_entry(entry_ref); + } + } didn't error out when dbid is invalid? pg_stat_vacuum_tables pg_stat_vacuum_indexes pg_stat_vacuum_database these functions didn't verify the only input argument oid's kind. for example: create table s(a int primary key) with (autovacuum_enabled =3D off); create view sv as select * from s; vacuum s; select * from pg_stat_vacuum_tables('sv'::regclass::oid); select * from pg_stat_vacuum_indexes('sv'::regclass::oid); select * from pg_stat_vacuum_database('sv'::regclass::oid); above all these 3 examples should error out? because sv is view. in src/backend/catalog/system_views.sql for view creation of pg_stat_vacuum_indexes you can change to WHERE db.datname =3D current_database() AND rel.oid =3D stats.relid AND ns.oid =3D rel.relnamespace AND rel.relkind =3D 'i': pg_stat_vacuum_tables in in src/backend/catalog/system_views.sql you can change to WHERE db.datname =3D current_database() AND rel.oid =3D stats.relid AND ns.oid =3D rel.relnamespace AND rel.relkind =3D 'r':