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 1nP6zR-0005Qr-FS for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Mar 2022 18:12:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nP6zQ-0006PM-0u for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Mar 2022 18:12:48 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nP6zP-0006PD-MC for pgsql-hackers@lists.postgresql.org; Tue, 01 Mar 2022 18:12:47 +0000 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nP6zJ-0007r6-9r for pgsql-hackers@lists.postgresql.org; Tue, 01 Mar 2022 18:12:46 +0000 Received: by mail-ed1-x535.google.com with SMTP id w3so23092738edu.8 for ; Tue, 01 Mar 2022 10:12:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=1fbR5VMynK1cGSgHkb86Mp9oKecjewvvljIvgITMOg4=; b=UpGk13L+6w4JekHEzlj1OXkZHwvrG1p2gD84i7QNLbOMSEir8x3Ji2MMmosIwsDe81 h1x7B6HTNUyWV6a3cu45Dk2mKzdEzMa78HYJU27avh6xIpCAeZgvjpvEC0BB4eDCvSMj 7eOSC8V95ce/KPXwkA9QNlnxS4Bjf1Tsvlj0/5yNhlJaxAjeivRt6eDc7qiZ4SsEVXbH Ryiw7KAGmPzhb2L5qtDrnK9RpBlo+qzkhTntdFlCoMyY6N4z92BJa6GVIAPI5EY8Ctm8 9B1aYApvmUkn0gFcf3GQdbJIuKEC19ssY8gYuvdUGtseMtsBUfdjz68z5ovpPHCn3cvx Up6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=1fbR5VMynK1cGSgHkb86Mp9oKecjewvvljIvgITMOg4=; b=drBHvPVh66at9OW3MWoVmVccrtbqyLCoXcNQs3lE50uylxqD/CCFahM57OhPjaTzhf K4/C3LO9t++PvlaQ0fmVMPMDI/VMnszKX6+yRyW/KPjVbb4ED724Z6LHTCi6pIxmAHv1 uWwPHkghGHMMLTmtuzeQ/NxxDQ7nD82VsW0qle0y6vQZJorL05omScX+gxiOm8tX3fja 9NwNFjCH2mqQoAZPLGyao1prrl7wLFi6U4QzYdg1Gq3mr8C+Iurk4xNGCOLTW81p/Xuh PsB/UrebxYAOkeDEPlNHhuRxK/9fOKGkMm15SSUAI5v+zpXh1gE6qy8FR9G4DXQbN1+s KL2g== X-Gm-Message-State: AOAM532GgPGCjCOhmk/dmJSzKtFV+uvimXQfXskqwzwftYFGOQVVPwd5 eLzvp4JF9LL0+8rk3OODzTeLdoADO3zoxen1n1iLOCNo0WE= X-Google-Smtp-Source: ABdhPJyM0QUU59VdOL8WFQmLVCfyLY1kUEgFxzFUTGIFcaNRqXZyQJLxIndiotwO3zPgN3en5FwsLeBZS7uYjGL0Ve8= X-Received: by 2002:a50:da8b:0:b0:415:a122:d7ad with SMTP id q11-20020a50da8b000000b00415a122d7admr1477248edj.123.1646158359407; Tue, 01 Mar 2022 10:12:39 -0800 (PST) MIME-Version: 1.0 From: Nitin Jadhav Date: Tue, 1 Mar 2022 23:42:02 +0530 Message-ID: Subject: Refactor statistics collector, backend status reporting and command progress reporting To: PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, Following are the files related to PostgreSQL statistics collector, backend status reporting and command progress reporting. pgstat.[ch] - Definitions for the PostgreSQL statistics collector daemon. backend_status.[ch] - Definitions related to backend status reporting. backend_progress.[ch] - Definitions related to command progress reporting. progress.h - Constants used with the progress reporting facilities defined in backend_status.h pgstatfuncs.c - Functions for accessing the statistics collector data There is a scope for some refactoring here even though the backend status and command progress related code is separated from pgstat.c. 1) There is a lot of confusion between progress.h and backend_progress.h. Why 2 header files required for the same functionality? I feel progress.h can be merged with backend_progress.h. 2) The access functions related to statistics collector are included in pgstatfuncs.c file. This also contains the access functions related to backend status and backend progress. I feel the access function related to backend status should go in backend_status.c and the access functions related to backend progress should go in backend progress.c file. If the size grows in future then we can create new files for access functions (like backend_status_funcs.c and backend_progress_funcs.c). 3) There is a dependency between backend status and command progress reporting but the corresponding functions are separated into 2 different files. It is better to define a new structure named 'PgBackendProgress' in backend_progress.h which consists of 'st_progress_command', 'st_progress_command_target' and 'st_progress_param'. Include a variable of type 'PgBackendProgress' as a member of 'PgBackendStatus' structure. Please share your thoughts. If required, I would like to work on the patch. Thanks & Regards, Nitin Jadhav