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 1jKdrj-0003fJ-TY for pgsql-general@arkaria.postgresql.org; Sat, 04 Apr 2020 08:09:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jKdrh-0002sQ-J2 for pgsql-general@arkaria.postgresql.org; Sat, 04 Apr 2020 08:09:17 +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 1jKdrh-0002sF-B9 for pgsql-general@lists.postgresql.org; Sat, 04 Apr 2020 08:09:17 +0000 Received: from portal-smtp-out.hot.ee ([194.126.101.125]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jKdrf-0003V7-0c for pgsql-general@postgresql.org; Sat, 04 Apr 2020 08:09:16 +0000 Received: from localhost (localhost [127.0.0.1]) by vm-hot-relay10.estpak.ee (Postfix) with ESMTP id 9CEF2C24; Sat, 4 Apr 2020 11:09:12 +0300 (EEST) X-Virus-Scanned: Debian amavisd-new at vm-hot-relay10.estpak.ee Received: from portal-smtp-out.hot.ee ([127.0.0.1]) by localhost (vm-hot-relay10.estpak.ee [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LNF0TQidCY+S; Sat, 4 Apr 2020 11:09:10 +0300 (EEST) Received: from mail.hot.ee (hot-relayhost3.estpak.ee [213.180.2.81]) by vm-hot-relay10.estpak.ee (Postfix) with ESMTP id 70018E41; Sat, 4 Apr 2020 11:09:10 +0300 (EEST) Received: from dell2 (82.131.99.74.cable.starman.ee [82.131.99.74]) (Authenticated sender: kobruleht2) by HOT-Relayhost3.estpak.ee (Postfix) with ESMTPSA id 48vTwP2217z2Ht; Sat, 4 Apr 2020 11:09:08 +0300 (EEST) Message-ID: <7C033DCE8AD84649B95C5B367D6063B3@dell2> From: "Andrus" To: "Laurenz Albe" , "pgsql-general" References: <45AE45823FB844ED80186DE14DCC5B14@dell2> <5DB1E9D2ADDB4BA0ABDF602235234BCC@dell2> <1e7536de1cb9e1097d1c8faf07a08bf66d8eeead.camel@cybertec.at> In-Reply-To: <1e7536de1cb9e1097d1c8faf07a08bf66d8eeead.camel@cybertec.at> Subject: Re: Using compression on TCP transfer Date: Sat, 4 Apr 2020 11:08:56 +0300 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="UTF-8"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal Importance: Normal X-Mailer: Microsoft Windows Live Mail 16.4.3528.331 X-MimeOLE: Produced By Microsoft MimeOLE V16.4.3528.331 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi! >> In case of varchar field values will appear in database sometimes with >> trailing spaces and sometimes without. >> This requires major application re-design which much is more expensive than >> continuing using char fields. >A simple BEFORE INSERT OR UPDATE trigger would take care of that. Changing char to varchar will break commands where trailing space is used in comparison. For example query create table test ( test char(10) ); insert into test values ('test'); select * from test where test ='test '; -- note trailing space does not return data anymore if your recommendation is used: create table test ( test varchar ); insert into test values ('test'); select * from test where test ='test '; -- note trailing space In production 'test ' is query parameter coming from application with possible trailing space(s). Adding trigger does not fix this. How to fix this without re-writing huge number of sql commands? Andrus.