public inbox for [email protected]
help / color / mirror / Atom feedFrom: David G. Johnston <[email protected]>
To: Simon Connah <[email protected]>
Cc: pgsql-novice <[email protected]>
Subject: Re: Stored procedures
Date: Sun, 27 Aug 2023 07:15:28 -0700
Message-ID: <CAKFQuwa7agwXq=W+eY+52u=4HMYSviQJo=1OVB4HWwxQmmNhxQ@mail.gmail.com> (raw)
In-Reply-To: <eXWbA7jWtEDZQJSHx3brQYIZX_tj1kEjvG3B1-Sye_0OaGrlBTBRWZ27b_lUuq2wjftN7LfdCbxWy-zfz1dYKXjckquiXaoLh_0CdaP96zI=@protonmail.com>
References: <eXWbA7jWtEDZQJSHx3brQYIZX_tj1kEjvG3B1-Sye_0OaGrlBTBRWZ27b_lUuq2wjftN7LfdCbxWy-zfz1dYKXjckquiXaoLh_0CdaP96zI=@protonmail.com>
On Sunday, August 27, 2023, Simon Connah <[email protected]>
wrote:
> I'm building a website in Python using the Django framework and am using
> the 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
> compared to queries you generate using Python and then send to PostgreSQL?
> I would assume they would as there is less communication between the two
> sides 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
> them faster than one-off queries?
Forget generalities. Do what makes the most overall sense. If a specific
case seems to need performance optimization then do both and measure.
If you are using plpgsql as the implementation language, or anything but
the atomic SQL format actually, you aren’t avoiding the parsing of the code
and are adding overhead that raw SQL doesn’t have.
David J.
view thread (4+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Stored procedures
In-Reply-To: <CAKFQuwa7agwXq=W+eY+52u=4HMYSviQJo=1OVB4HWwxQmmNhxQ@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox