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 1qaEGi-008aaV-Vt for pgsql-novice@arkaria.postgresql.org; Sun, 27 Aug 2023 11:49:25 +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 1qaEGh-00GnCW-A3 for pgsql-novice@arkaria.postgresql.org; Sun, 27 Aug 2023 11:49:23 +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 1qaEGg-00GnC9-Uc for pgsql-novice@lists.postgresql.org; Sun, 27 Aug 2023 11:49:22 +0000 Received: from mail-4316.protonmail.ch ([185.70.43.16]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qaEGY-001EAX-UL for pgsql-novice@lists.postgresql.org; Sun, 27 Aug 2023 11:49:21 +0000 Date: Sun, 27 Aug 2023 11:49:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1693136950; x=1693396150; bh=RkLO6PY6XxGNLQ7E60+OXUZm+QCOhWr+gyhHijFdVlc=; h=Date:To:From:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=Qk1bcuRG3iORV1c0CMcBB13doHpMWB+DPLABYPbQ3CZ7zAUOOIwthKSx5hCmF6bw8 9sxfzHGnjyh21FQ2T9ZDYGau8tpUUULI89qly+tCxlephzPLcRZjq1X+U9BRp1wFWx g3lYFNARUZp4ZxftnBvM2xDRXCmpxGVsBWFrl28ER4aanxoQ+3r/5ceHPBmDzpiYco lmI+ef8vpOUZZJonr8vm/Fmcc5YjaFUPwskW3wRYkpNIJIZStZWqekV1m27Ojqujbm sbbRyeAFH/d6ap8KLtdWbdgbwTepD4Xy01La7kT9S04lcMoIT3/6qqxoqe1mJwwvoS 7bWE1NNR3ITYw== To: pgsql-novice From: Simon Connah Subject: Stored procedures Message-ID: Feedback-ID: 24074989:user:proton MIME-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg=pgp-sha512; boundary="------e1eb30d33142953f69ed11dd60010fd858bfa8d6d497e2609fdefd86b09fff08"; charset=utf-8 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --------e1eb30d33142953f69ed11dd60010fd858bfa8d6d497e2609fdefd86b09fff08 Content-Type: multipart/mixed;boundary=---------------------82dd2e0cc386424daf445f2d14ceb363 -----------------------82dd2e0cc386424daf445f2d14ceb363 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain;charset=utf-8 I'm building a website in Python using the Django framework and am using t= he ORM at the moment but I can see a few situations where I might need to = write raw SQL. My question is do stored procedures execute faster when com= pared to queries you generate using Python and then send to PostgreSQL? I = would assume they would as there is less communication between the two sid= es and also because PostgreSQL knows the stored procedure ahead of time it= should be able to better optimise it. Is that true? Does PostgreSQL use a JIT for stored procedures which make t= hem faster than one-off queries? Simon. -----------------------82dd2e0cc386424daf445f2d14ceb363-- --------e1eb30d33142953f69ed11dd60010fd858bfa8d6d497e2609fdefd86b09fff08 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: ProtonMail wnUEARYKACcFgmTrOCgJkFrvKC74ta6lFiEEXOYF9uqFRn4815bYWu8oLvi1 rqUAAIlTAQDHY8TK9wBaC4oYOSUhGprR4MmZv1csYX6oPQhsJBmvdQEAoU5n A9y73uod+G2J+C772QDiWjgldG7yjZ+cr54Dtg4= =GMdM -----END PGP SIGNATURE----- --------e1eb30d33142953f69ed11dd60010fd858bfa8d6d497e2609fdefd86b09fff08--