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 1ujcsB-009yM7-MB for pgsql-general@arkaria.postgresql.org; Wed, 06 Aug 2025 12:04:00 +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 1ujcs9-00FQJj-BB for pgsql-general@arkaria.postgresql.org; Wed, 06 Aug 2025 12:03:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ujcs8-00FQJb-W6 for pgsql-general@lists.postgresql.org; Wed, 06 Aug 2025 12:03:57 +0000 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1ujcs6-0013du-1C for pgsql-general@lists.postgresql.org; Wed, 06 Aug 2025 12:03:56 +0000 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-3b78bca0890so4021821f8f.3 for ; Wed, 06 Aug 2025 05:03:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=connah.dev; s=google; t=1754481833; x=1755086633; darn=lists.postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=aEUvV15nueqYYZRVLkdCY30SHAXUVB7CYuyyimLtaFA=; b=EJEtvTfn1x1bCVbU0UonKiBNBzS8TRQ0PvTj5DN0fRIfrF8MxtaH/Jrnjdd+R3ra/7 HtJqnm25DlWooTlZo1lDbvJDtsH1WBuKewF7UlBQgqrXFL9sW/E8lY/Hqg/J0O3GJV/W bxrBxUrUbVBe3NEvIf+/s7So/PBqHtlRH9Bg9dGaUC1zvJHAqggkaUEYGKy0baeRZfEH 7oxOy0GyxCNtydaM0Hv4luUXC/ygjJo7OZgjgJV1QV8cUxqhkioTdqoG4/jrKxdSt4jt HGBHpRB8Ondp7IKNsmCtphkLzfCaeH0OSPVXM/C65lY6unVYcmp65Ftl4UF+jOijY6dX +WEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754481833; x=1755086633; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=aEUvV15nueqYYZRVLkdCY30SHAXUVB7CYuyyimLtaFA=; b=T6w/mqx+Zw4yEsHqBMZjwWMLg7+xH9fSd/Zo+ANDRzk04hu3F9Lq3X5fdqfqdigUy3 tVrtuIYpipN8nlfdKpJXG1REDl+Y21diDKbGHWZixTXk7vs/4eGnmOf4F+09FNGG7VE5 QQTDVfWxo1jLzBbBqBLc30eCVdz1I1JyoWlYJ/7+vS9KLwTBfvjUydff0j0OehekDI1+ PMghsNOHbBKTvtGFHd7LZb2Fmh0rqk+v5JFQ3//ElmG5PPvIjohLWyC6f4Vu/6BT/aAQ k+GuSJiZ45bSgrOgUm0iaduzCXz66NnXmn4c019Sy4pXY3w+mV1FN1mky3fiBY50cpJU zxgw== X-Gm-Message-State: AOJu0Yz9WZ5alBz7M4hM+OrNsDKnIzXgefdEOXPKjHh5C5Fk5Saxd1Hi ubru+M7L2R/3BjmTg+up3rJksakswFkaw5+Fe9+Koj6pxVDWeer8aSxJ0vpZR+JO+2M8NbemWPt 608UhOCHVhNLCq/sB2u6Hh0gVHLX5TjzO3sWTvmad7kBJzBPKibM2UUg= X-Gm-Gg: ASbGnctqb/QSvg9mfgiWyUtDUc2mL+tq/evC0kSdE4yESt9QxiOQR/Gtf0Jh1wjT0at CIVDZnJpDn4R5K81WY1yitcnQk3ylqoyDVNx6otNdk75xlamyZGMBuITFV2nbKkPQ83ezt18BBB wGg8LzxT1gR133fY+j76yIIQ/AWV4LdooGo03eTAoDWOekYSeled/P+RYmk1bJK+k/1pRRmVIRz Tk= X-Google-Smtp-Source: AGHT+IEPPlPn0fKAkhIXdcfqicHCIwbKKiMRCi3vhF9i4TP5j6bsujyFj6fRabMWJ71zlQChIQG59MMXHNkiWT6mzVQ= X-Received: by 2002:a05:6000:4305:b0:3b7:e3c3:fb9f with SMTP id ffacd0b85a97d-3b8f41b5be5mr2227818f8f.49.1754481832800; Wed, 06 Aug 2025 05:03:52 -0700 (PDT) MIME-Version: 1.0 From: Simon Connah Date: Wed, 6 Aug 2025 13:03:41 +0100 X-Gm-Features: Ac12FXxqfUugBPJ-Fyh7ibtR4W3RCzI4YRqXY9VQ3WYmwDi5TcfhoO4mURmQLZw Message-ID: Subject: Stored procedures or raw queries To: pgsql-general@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, I'm pretty new to PostgreSQL and am building a simple website with it. My main question is whether I should use stored procedures / functions or whether I should embed raw SQL queries in my backend? I understand that procedures are faster as it cuts down on the round trip speed and the database can optimise it better. On the other hand raw SQL is much easier to manage as you just change the query in your bankend code without having to apply changes to the database at deployment time of your backend. What is considered the best approach? My backend is written in Go if that makes a difference. If you need any additional information then please let me know. Simon.