From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Simon Connah <simon(dot)n(dot)connah(at)protonmail(dot)com> |
Cc: | pgsql-novice <pgsql-novice(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Stored procedures |
Date: | 2023-08-27 14:15:28 |
Message-ID: | CAKFQuwa7agwXq=W+eY+52u=4HMYSviQJo=1OVB4HWwxQmmNhxQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On Sunday, August 27, 2023, Simon Connah <simon(dot)n(dot)connah(at)protonmail(dot)com>
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.
From | Date | Subject | |
---|---|---|---|
Next Message | Gurjeet Singh | 2023-08-27 15:55:06 | Re: Stored procedures |
Previous Message | Simon Connah | 2023-08-27 11:49:06 | Stored procedures |