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 1mj2fh-0005Uo-UO for pgsql-general@arkaria.postgresql.org; Fri, 05 Nov 2021 17:06:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mj2fg-0003b4-2b for pgsql-general@arkaria.postgresql.org; Fri, 05 Nov 2021 17:06:32 +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 1mj2ff-0003Zy-KR for pgsql-general@lists.postgresql.org; Fri, 05 Nov 2021 17:06:31 +0000 Received: from sonic305-20.consmr.mail.gq1.yahoo.com ([98.137.64.83]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mj2fY-0000KB-Qg for pgsql-general@lists.postgresql.org; Fri, 05 Nov 2021 17:06:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1636131983; bh=tNKvOND955jzrkWSOjxvMQzE8Be1YoxMaoN9ptMOQN8=; h=Date:From:Reply-To:To:Cc:In-Reply-To:References:Subject:From:Subject:Reply-To; b=sxicukgFoW6M3YmtzLgNptORYpgVsjWBBW4xydMoh76rGHvC4J15jrNdtwhGsmU2x/3VDahnfYrdtpndT0Ku6LuFsoqH9FPpBUJavNFTXexCcXkWs5/m8fQC6o/5Y7pZ6rbbnrR0dm5scsF5NBOaxN3rHyPu9GdVsAtbkAzloYJHJ0k0MmToI8O+Huhxw9DzVDD4JVOo0Vk4fY7TtJQAniHra4ulja+0J+ij1dNa3Cdg4KuO889nTLkMOMFDpcxkOYfjOO/uh8m5SYOZgqlMWvBouaemS1doOl8R3UJYqDHtOzmMIdC2LWt1IwBZnzcYXpy17i5PyKTywiH1Sd3ctA== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1636131983; bh=CPUF7dDsEFc3mZe3j3c083qecoRvAvRKlgX2IwrWls+=; h=X-Sonic-MF:Date:From:To:Subject:From:Subject; b=TE3H4rMhlN7HC9gRxaiZDW/JHEXtRbqUBEkR5TSS2t/aGnUzR5yICGtBUPWhXaqf72xY+bopwIBiBNetv+e3dUsYUIQlvIEwUzMAJubNskzW/rCsdbOzqTZXYZb/Qx223iheMeKIM8+ZPl4D8R5RRm+6CRev1VrstVVjjmJMivA/SOzbu+PWBqihzgx8g7YKlew8gGMQUvUHXz4srs4uuYzCJ/RRK1gmDuVqliwbUirFORJ8XN3GIbnAktd/48k+tw28VD7FsK4MxcQyz0gZFxW5SiudJmuiX11sBCdEIdv5gmVe98R8eYV3gn0eWtYDQZK42pXCyp32Q792KYL0DA== X-YMail-OSG: c8NQ0rkVM1mTz8vqr5vJMvSnAislc.bxRWBxWtSaIYzTyZhHiWLzKO5qjM5AOT0 ZjACLvng4xHPOnJe6Nqk8O6t6z4Zxy.wdD_sybIT_ydoc83LCYiRj086UcFCAyi9rzldPqghxujW mSs9_Jn7Wh.EOGruNGiO0IPOyYGYNFsLaF20jkJyqMJwnwNj5Hzd2K84kSQCfWadOpnEilnUEo.G 860uwje.StjU1e82iJHiRn80h3typoA77xYtdVYLXdBhaidKYyXsPg45mT6S_1QvXGNy.czUC7Q4 JCS4tPsf4cmXA6SPN1tZGviHakd0Lf5__F8tTqT_enUryTyvCnIM5IReace_TiantKDHMCc2VsFK e5Lsl0ufYZ3pdRAdl5UiTZgArPBbmxR9S.wuj0GffhfAVnIAAMXHTQlU4tsTiIkZwKVjPlG3_ulH o96ua88_Ii_vudd6W_5EU.uB46rLIaAVyWsNzsUSLYobneHPFzxE7ThrvabWV6VlWW48__eLiybj SCp95K7kqudNVsjRwUFn0lmyi8m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dHo6ZQ0sAS46LlyW_gmi.PVCZcvRiK.W.IEhkgrU7QfP8HGmLuI._z r3LW6Cz8He5BJ9i22LRHnNiBgtov2CsWbAvZb1s3Dbvh4QSuPY5FlsQozZ.zOBYrVED_4r5y4lPf THP2iVeNnXZUnQGUQUrT4Z.AauJYmm9pH_8ZBp3US5100Z51yPqVKEcQQqBJT4l0nwfzW46slK1m .BSseYBFOK6ABX8Du1EwQKkyMP7MnbddbI4BBCYGjlDcNUx0lz77QmqI5SXCSzt6eSZiPbGt4PzK iLXbjKp5SYOV0XuduxPxTfPrczZN4u3EG2_PBVXOy7rRrdBBQA5EDxd31ua3.hYFSVlEilN6BeU4 nUBH7.pVf8958QpuOZvcK_b211k_QdnymJNRfUD3h6d5zrdNDKAiENa2Xg7TOH4H7vP1SgfH3fKX CUkClxjcOeuZiEcZ135Z8uqNjzUGx_8mtp81UhSv6GcfMKtj4Fo8V93LlkwHI2OK7iu0cmys6Lqh 5UfdjFvnNs.LICdi_HFfVayQKZZhewVF.TbBZog9XkZjHbcfpmQ5s9aC3_z4BhKBx8osZfPGRTV4 VimTNaFt32fp3ogL_xLaNaguEzvf3n6v3aaJTwoiLmQotURbY3LBUDjv_yX.75Y7u3HE3XFJVwR1 MK3FkhQn4_fXZKGGQ_Z50W5T7dx1.UauI1XoQ2.gxWuuYABbQ92CyadlXec4DtfODizQwoPEKeTN iyeUQCBi7yvsN X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic305.consmr.mail.gq1.yahoo.com with HTTP; Fri, 5 Nov 2021 17:06:23 +0000 Date: Fri, 5 Nov 2021 17:06:20 +0000 (UTC) From: Boboc Cristi Reply-To: Boboc Cristi To: Tom Lane , Michael Lewis Cc: PostgreSQL General , "pgsql-general-owner@lists.postgresql.org" Message-ID: <1025476304.898402.1636131980837@mail.yahoo.com> In-Reply-To: References: <1395901381.802146.1636111701121.ref@mail.yahoo.com> <1395901381.802146.1636111701121@mail.yahoo.com> <412962.1636120304@sss.pgh.pa.us> Subject: Re: Debugging features needed MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_898401_230023239.1636131980835" X-Mailer: WebService/1.1.19266 YMailNorrin Content-Length: 6797 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ------=_Part_898401_230023239.1636131980835 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable =C2=A0 =C2=A0 Hi. =C2=A0 =C2=A0 If I am going into logging, then I would use SET_CONTEXT func= tion. It is too little documented, but we can add many pairs of (name, valu= e), like this:set_context('myvar.varname', 'my value here', false),set_cont= ext('abc.anyname', 'any value', false) The important part is that dot inside the first argument of the function. =C2=A0=C2=A0=C2=A0=C2=A0But I am looking for a feature that can be used liv= e, while inspecting the running queries. Thank you for the tip, indeed appl= ication_name seems to offer what I was searching for.Thank you also to all = people telling me about it. =C2=A0=C2=A0=C2=A0=C2=A0Setting context variables in conjunction with row l= evel security helped me 12 years ago (yes, as you can imagine it was an Ora= cle database) to "force" users perform the urgent tasks assigned to them (a= ll they could see were the urgent tasks, and only after solving those tasks= they could see other tasks) in the ERP software we were using at that time= . =C2=A0=C2=A0=C2=A0=C2=A0Relying on SQL comments is also a great solution, b= ut I find it a little hard to manage precisely. This is why I have not cons= idered it until now.More than that I am not a fan of the SQL statements emb= edded in the application, because the application does not have a kind of S= ELECT statement to allow us inspect its metadata. (Yes, it may have reflect= ion, but reflection is much less powerful that SELECT is at database level)= . There are other reasons as well, but this one is the most important for m= e and for my current job. Best regards, Cristi Boboc=20 On Friday, November 5, 2021, 04:16:23 PM GMT+2, Michael Lewis wrote: =20 =20 For my purposes, app name isn't long enough so we put a comment at the sta= rt of every SQL that has a unique ID generated in the application. This ens= ures that we can tell one connection apart from another even when both are = coming from the same feature/action (applicationName is set to this) even u= sing connection pooling. Before, we had different requests reusing the same= pid of course and if they happened to have the same appName, we didn't kno= w it was a new process on app side. We also log that same request ID to NewRelic and when an app process needs = to use multiple databases, it links those for research of events after the = fact as well. I would be interested to hear what others are doing. =20 ------=_Part_898401_230023239.1636131980835 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
    Hi.
    If I am going into logging, then I wo= uld use SET_CONTEXT function. It is too little documented, but we can add m= any pairs of (name, value), like this:
set_context('myvar.varname', 'my value here', false),
set_context('abc.anyname', 'any value', fals= e)

The important part is that dot inside the first arg= ument of the function.

=
    But= I am looking for a feature that can be used live, while inspecting the run= ning queries. Thank you for the tip, indeed application_name seems to offer= what I was searching for.
= Thank you also to all people telling me about it.

=

    Setting context variables in= conjunction with row level security helped me 12 years ago (yes, as you ca= n imagine it was an Oracle database) to "force" users perform the urgent ta= sks assigned to them (all they could see were the urgent tasks, and only af= ter solving those tasks they could see other tasks) in the ERP software we = were using at that time.
    Rely= ing on SQL comments is also a great solution, but I find it a little hard t= o manage precisely. This is why I have not considered it until now.
More than that I am not a fan of the S= QL statements embedded in the application, because the application does not= have a kind of SELECT statement to allow us inspect its metadata. (Yes, it= may have reflection, but reflection is much less powerful that SELECT is a= t database level). There are other reasons as well, but this one is the mos= t important for me and for my current job.

Best regards, Cristi Boboc


=20
=20
On Friday, November 5, 2021, 04:16:23 PM GMT+2, Michael= Lewis <mlewis@entrata.com> wrote:


For my = purposes, app name isn't long enough so we put a comment at the start of ev= ery SQL that has a unique ID generated in the application. This ensures tha= t we can tell one connection apart from another even when both are coming f= rom the same feature/action (applicationName is set to this) even using con= nection pooling. Before, we had different requests reusing the same pid of = course and if they happened to have the same appName, we didn't know it was= a new process on app side.

We also log t= hat same request ID to NewRelic and when an app process needs to use multip= le databases, it links those for research of events after the fact as well.=

I would be interested to hear what= others are doing.
------=_Part_898401_230023239.1636131980835--