Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ins3V-0001Nz-1Y for pgsql-general@arkaria.postgresql.org; Sat, 04 Jan 2020 22:38:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ins3T-0004mZ-3t for pgsql-general@arkaria.postgresql.org; Sat, 04 Jan 2020 22:37:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ins3R-0004mS-0z for pgsql-general@lists.postgresql.org; Sat, 04 Jan 2020 22:37:58 +0000 Received: from [66.111.4.26] (helo=out2-smtp.messagingengine.com) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ins3L-0001fG-CJ for pgsql-general@postgresql.org; Sat, 04 Jan 2020 22:37:56 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 5213B21CBA; Sat, 4 Jan 2020 17:37:39 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Sat, 04 Jan 2020 17:37:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=e I64N+RYBysxKjgHUrz4xY+Jwm3W+eM0mUB+PAIAhMo=; b=Ht+Da0F7Lwh9Fr+X3 wpqrZ5Q6mVvdPRRJQw1Cxa6NxNoC2664WRXxf7fxQv1+95moQWdGkgXiBE8or98a l57eelhGNdXXSfwgdj/3UgVbRRk1NfihDDKC3v0B7hU4svBEWeORfvc7w4TpoGfT 0srC9KjAylwCVhpEcfSB4ug4Eecka7FAbg5oRdaCmLK5ljitu5MIFlIjlIrylQMU UzAxPw/1HQ/nd09uAZdqHm0Dmb+eiP/g4t/e3jr7PDCdwCPX5xlYe9hoDEVk3/Yq /EiId5eVgrhlqFt7XXCuh2rKw4zF7yg6bfKIik5NCW7LhQp7UvEAJbVNbKNYUJ4B ULRHQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=eI64N+RYBysxKjgHUrz4xY+Jwm3W+eM0mUB+PAIAh Mo=; b=WKrSyV5Cys6MRLKUk0ollZmuauVzppQ1Sa2IOoHIkaqHKRtUoBz262CNe SfvDKoWJrJhq3aSaCUpBxkRe55ffhrJx3IlnNs717VBwSMZ5yACb20eQrMGwzzQ9 iev4YhOIY8AmSIaguh80xbDKzRpGK32S5C2rkqrM4JlYoW8YY667hqjbPjXwB7oP Ra6Z1PDMpq0+KYh9+v+qpd7FX4j0nnPeaNLNmyGQf3kXp8K9G94ijwyH7Qx2Uyvm 6H24zOIdEeLiTk69O029mPSc6yM+fEPAR3vry4r+7Rpo/DI9BsDfgK7Z82PxwBUE BxS5v4cUgq6EW/HbsM9gG83SwLzRw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrvdegiedgtdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthekredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucffohhmrghinhepphhoshhtghhrvghsqhhlrdhorhhgnecukfhppeejuddrvddu vddruddvledrudelfeenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghnrdhklh grvhgvrhesrghklhgrvhgvrhdrtghomhenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from [192.168.1.10] (unknown [71.212.129.193]) by mail.messagingengine.com (Postfix) with ESMTPA id 41B873060774; Sat, 4 Jan 2020 17:37:38 -0500 (EST) Subject: Re: When should parameters be passed as text v. binary? To: Paula Kirsch , Justin Cc: Andrew Gierth , "pgsql general (pgsql-general@postgresql.org)" References: <87blrjktdo.fsf@news-spur.riddles.org.uk> From: Adrian Klaver Message-ID: <74b122e1-e683-e3d1-35e2-52e92ff8a1b4@aklaver.com> Date: Sat, 4 Jan 2020 14:37:37 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 66.111.4.26 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 1/4/20 2:13 PM, Paula Kirsch wrote: > Good point and I loved the way you put it. More low level stuff I need > to learn. > > I'm still struggling trying to find the list of data type oids either in > the documentation or in the postgresql source code so that I can specify > the data correctly (assuming, of course, I make sure the binary on both > sides is compatible. > https://www.postgresql.org/docs/11/catalog-pg-type.html select oid, typname from pg_type; If you want the source code version: https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/include/catalog/pg_type.dat;h=fe2c4eabb46dac36297699366d7574824238ecf2;hb=HEAD > Thank you. > > On Sat, Jan 4, 2020 at 3:30 PM Justin > wrote: > > As noted by Adrian what is the USE CASE > > As a general rule one wants to use the format the data is being > stored in.  every time data is cast to another type its going to eat > those all so precious CPU cycles.  (all the horror of electrons > turned into infrared beams) > > converting Bytea type to a string encoded in Base64 adds 30% > overhead.  converting an integer tor ASCII can add allot of overhead. > > The answer is it depends on the USE CASE if casting adds any > benefit.  my gut tells me it will not add any benefiet > > > > On Sat, Jan 4, 2020 at 1:59 PM Andrew Gierth > > > wrote: > > >>>>> "Paula" == Paula Kirsch > writes: > >  Paula> I'm just trying to understand the trade-offs between > sending >  Paula> everything always as text, all integer parameters as > binary, >  Paula> floats as binary, etc. > > For passing data from client to server, there's no particular > reason not > to use the binary format for any data type that you understand (and > where you're passing the data type oid explicitly in the query, > rather > than just leaving it as unknown). > > For results, things are harder, because libpq is currently > all-or-nothing about result type formats, and if you start using > extension types then not all of them even _have_ a binary > format. And to > decode a binary result you need to know the type, and have code to > handle every specific type's binary format. > > -- > Andrew (irc:RhodiumToad) > > -- Adrian Klaver adrian.klaver@aklaver.com