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 1v2OaK-003CHj-Hb for pgsql-general@arkaria.postgresql.org; Sat, 27 Sep 2025 06:39:08 +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 1v2OZI-008HZU-W6 for pgsql-general@arkaria.postgresql.org; Sat, 27 Sep 2025 06:38:05 +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 1v2OZI-008HZM-Ko for pgsql-general@lists.postgresql.org; Sat, 27 Sep 2025 06:38:05 +0000 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1v2OZG-0009SL-21 for pgsql-general@lists.postgresql.org; Sat, 27 Sep 2025 06:38:04 +0000 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-46e3ea0445fso6807095e9.1 for ; Fri, 26 Sep 2025 23:38:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1758955081; x=1759559881; 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=xzUCQXVdcCufQL5FQq8f68Z/i7s8b+TZQIKXdM0L3gc=; b=IbN1gs2N8d+hWb+dt1T5YICOO99yOnE3PSY9Ulq8IxKBixsRHIttu9kmE9LS/RMou+ Bm9Vf41zxGfoxJlpkhOUs/Oxg1qxhvlZHE+HnUqUp1zOeVSMZfriMfq8prGZgLTuJ35z qnr4fF7uFv54H3OCRGwNNNcwa7vVY5ItMsq6hRUXxa407oKD0BTvyets0Lh3u5fL64Xx 4igEoxkSVFNnq/blyMniU4ChVHG8bx0q98TYf5KuHr52Ozpf6Bo+k1EiYrFOfpq0JYhT tACoPLnfEbSnX06RoQ7/mkIePQEA5/154YLXMu36pLJapow/IbSfJdYIC77Gz1ijM0an 2R/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758955081; x=1759559881; 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=xzUCQXVdcCufQL5FQq8f68Z/i7s8b+TZQIKXdM0L3gc=; b=VFuVrZsmWxs0acHl1kwpj8OKipleHvaN+F5hICUXZWAuaTiOctCpWoKvVwnONIwOL4 OCkj6y86iwEb9Zi9oWC61r97fvjp7AaqmBL0g6vh6GZjcEvoSJzKJxmRnjXMt9WJ3AzD gfZRhC1RBc/QiXpt1evRK6eAgUPY6vxBalneUbJ/9ykDLZE/k73mn/AfJJ11jHI++FR4 cId8Qy+ZpRVTXtnlZLg+dPeUNZ8IYJThJDCNWwFtqGVLQAJnoD/4pfWzxQWqYUXm3mgT 4UDPLSrsrDM6uZXb0T37G3h8DGxm5ssbzn2wiu/He5C6vCVKkI2pOgE8yYbLc0HAqnQ7 utWQ== X-Forwarded-Encrypted: i=1; AJvYcCUMxxhflpmBbQhCroULeTkdjsq46/VDnuhos7T5aslGOjVp7S+VVz4u5w1NjuL90DRfT3AjJ0Nt1vYqG9Eg@lists.postgresql.org X-Gm-Message-State: AOJu0YyozZPXluWDVnzPNQHO6cjDL+bRdyP/+EjBctkculhbbiw+PcsK LH/nuD6Q0QlG64XXyzAKFbt0admcdrxwacgTlGQyrYVKsdfHvVt2FI1Fg7jLETbq7uI= X-Gm-Gg: ASbGncvGhhzgO/bxc2ypXCQ6D5O9N4ZcykIn6ycgeTI0+CAjSLVBlbY8puSETOWbutJ 2ChWXdGTaOKLi0geG6z3DO3DAz16WJaypj+REtITrsEoySPN/0G7ZF0Xu4cpUnIo3ZBv1rgdaef MewDDNbhh24eSOoXr1GXB1vVjF1PbGOPlv/590T8sSm6rPu+/HUr0jfxGovaafAl4J2VVeVdZ9q 4sDZ7MwHOIbc1bFGM9vCuLCnp5rTzC+SnytNsDDvhLutAs4iT+RLR801d32bHyTz79xNGzkA8GM l3TUpcFoWIRnZ4IcDjcSj74KFPizsIIr9rBJ2GKFCGqLm3Nh+zLP1qUBoV/kZwBS2q8gDqJ5bnt CwHYfJMwTwqkMWR/9WBMCNSVj69h1guKoZTh2JaBeKVfpLMOQ3ufNQKg= X-Google-Smtp-Source: AGHT+IEwc6MKJ6uLEyrQMGZV65mzYRhtrreIkfy377jtgpapj5BWG53/Oc9aGhUBrfB1aZC4KKQYjw== X-Received: by 2002:a05:600c:4683:b0:45d:e28c:875a with SMTP id 5b1f17b1804b1-46e32a16bafmr106231975e9.31.1758955080662; Fri, 26 Sep 2025 23:38:00 -0700 (PDT) Received: from laurenz.albe-K4N0CV00F97414D ([2001:871:270:b3a7:5d5a:5d5c:3780:cfe0]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-40fb985e080sm9587618f8f.24.2025.09.26.23.38.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Sep 2025 23:38:00 -0700 (PDT) Message-ID: <5f7b22937061ee8cbe0df08930b6ef2c93624095.camel@cybertec.at> Subject: Re: Correct query for monitor From: Laurenz Albe To: veem v , Ron Johnson , pgsql-general Date: Sat, 27 Sep 2025 08:37:59 +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-2.fc42) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sat, 2025-09-27 at 01:45 +0530, veem v wrote: > If we want to identify, what exact query=C2=A0inside=C2=A0a procedure is = taking a longer time: > - Using any pg_* views, Is there an easy way to tie the query_id of the p= rocedure > with the query_ids of the internal sqls(those are executed within the pro= cedure) > to quickly get the culprit sql? No, you have to read the function body. Then you can look for the statemen= ts therein in pg_stat_statements. > And say , we got the=C2=A0sql and saw a bad plan and we want to change th= e plan or attach > a good plan to that query , is there a possible way to do=C2=A0that in po= stgres? No, there isn't. You can use the pg_hint_plan extension and its query hint= s to force a certain execution plan. Yours, Laurenz Albe