Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cFU6I-0000O0-TA for pgsql-general@arkaria.postgresql.org; Fri, 09 Dec 2016 22:57:11 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cFU6I-0001DB-Fq for pgsql-general@arkaria.postgresql.org; Fri, 09 Dec 2016 22:57:10 +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_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cFU6H-0001Av-6r for pgsql-general@postgresql.org; Fri, 09 Dec 2016 22:57:09 +0000 Received: from mail-pg0-x232.google.com ([2607:f8b0:400e:c05::232]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1cFU6A-000336-82 for pgsql-general@postgresql.org; Fri, 09 Dec 2016 22:57:08 +0000 Received: by mail-pg0-x232.google.com with SMTP id x23so12270131pgx.1 for ; Fri, 09 Dec 2016 14:57:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Y/NWleJ6/WGXWFSqR0mpOsQEpkxFvMrMzHHTgVXek7w=; b=M9ocrXs7a5UBfyHl7zhrPqrbFnpJjAUFwp7gWYq7hGVLoGzhXnSKjdSGgpTPrb5d2l EUqfbl/zIFMC3lcWc2lQpL8JjxURUJEC81htpKLfy/d5FF+pGYD5U8MRXyTcHQ6y28yt opduqS7c3OZm+W+09rAztxCUKHB2a1w2XyJYvBZIvCYdbimlx00EdiSri3SkRtfd1ZvQ YRaP7t3OksilJyv7g9fOv/ai/qNyu9CB9OhsiFhnEVzfRIwLw9gwOHwF6f85l/O8QOEO +Iga6HcrdDx+ryE7VBoMyoBHsaJEkqJ3vwevsIq8fiPq1slqXSTq4WTmUeDJXrvheu4d Bk+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Y/NWleJ6/WGXWFSqR0mpOsQEpkxFvMrMzHHTgVXek7w=; b=gIRxQq4U6oQXmOoKYARwoN//o9sykRTJ73mXADtKIRH4ybPUNvcsqyC4GMJrAoxb6C thUKe4rrILKGR0RuhfEVQ7hScwgIpRb/akRt2hSJaLh/NSOuNLAt0m7v65aBz5xQhGi7 3Sy/WKsa7+wHlXNMnJXSkcjMvl7N1ssqeM6K2NTnzv/m+7p90Xk88AFf0yRBS1+mT6CR A2ESvUmbeDB/uaRxkKOUUmfq37B97NPddMdSRpGAmAa4vUm7SIRxEaZafkLEHtKRxj2s AL1L9YLb+hWQvbwYYHPrZvUrxzJMW1nYRRuUx33mHKSwz8GDCg1EuOwqwJC0Wq9hdhcD N5Dw== X-Gm-Message-State: AKaTC01aS5Fuv2NeD5v/yIQtcUaLNl+XgIt1jU4smbuk59i2fPuGid6p+vpBXCKBoxDZKg== X-Received: by 10.99.161.2 with SMTP id b2mr151206632pgf.2.1481324220022; Fri, 09 Dec 2016 14:57:00 -0800 (PST) Received: from paquier.xyz (27-139-10-71.rev.home.ne.jp. [27.139.10.71]) by smtp.gmail.com with ESMTPSA id d15sm59841476pfl.46.2016.12.09.14.56.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Dec 2016 14:56:59 -0800 (PST) Date: Sat, 10 Dec 2016 07:56:55 +0900 From: Michael Paquier To: Andres Freund Cc: Qiu Xiafei , pgsql-general@postgresql.org Subject: Re: Is is safe to use SPI in multiple threads? Message-ID: <20161209225655.GA1553@paquier.xyz> References: <20161209223758.fkueb6bwiszmuatv@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="opJtzjQTFsWo+cga" Content-Disposition: inline In-Reply-To: <20161209223758.fkueb6bwiszmuatv@alap3.anarazel.de> User-Agent: Mutt/1.7.2 (2016-11-26) X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org --opJtzjQTFsWo+cga Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Dec 09, 2016 at 02:37:58PM -0800, Andres Freund wrote: > On 2016-12-09 16:52:05 +0800, Qiu Xiafei wrote: > > 1. Is there a way to use SPI in multi-thread style? >=20 > No. >=20 > > 2. Another option is to use libpq, like normal clients do. Is libpq as > > efficient as SPI? >=20 > No. To give more details here, Postgres relies heavily on the fact that sessions working in parallel on the backend should be done in separate processes, like for transaction or snapshot handling. --=20 Michael --opJtzjQTFsWo+cga Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAlhLNrcACgkQnvQgOdby QH06FQ//erVWIiBftpuVNWxreC0CDOCsaxyUfcQ6glQ0D0KbN6VNpxqJWOrTEG3H t2DKZFrBlum65+h5sBXNPdhrhYTpi0nc9RhbOaudLH5dE2xMTS/jIhDW4fGsuip3 Y2w7mDuiQ8ePt/8nqnZVMNlZnr4PIMnVjgxo9XJUusvi4ZMnoEOMBtwpHEOPFAoC H/ZgygJHoA6dHKQiNoe6T5q8p53y9rHYeZRo14aU5lLHbRQiW84jVMebMeNhQJc0 kwo6I82Ro5SoL1JeWT2TBE7GjmElOnO6Z2igFuY2qhXQ9rKMfyq6mj8L9eXKLYgS qB6UffKYQsn2N6SFVRn2kzzOep8qEg/xfhHl0os2zNx4uKG0FdJRM7JYAv/CzM7T 2my2A2wZ+xGXuooCtMdUDsrgBt3xXmDAKqivlRVD4y4MwKOug9nX+gBDH97CQXba 5wWXc4KMUXfuKN3KW7QpipF/CKPU6KHvs5y5epBKkVvtRo6+haUHY3ypKk97XyrH rw6GqBRX7010YX4bEgJMvqRFeiiKACz+egjCMAnAL8U2PD6hw3R+chbHwEaMs0iO RG6HqLoc04GApe2It7kZ463tfGtmi/RdAoJwQNV3jlTa/cNg/LrcZ2ClhXmnEKja nQAwUBKklw1LBDsS/Qb80rSHfn2/dIVwM5KUIPdu+ntK966a8uo= =1CJ4 -----END PGP SIGNATURE----- --opJtzjQTFsWo+cga--