Re: Stored procedures

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: Stored procedures
Дата
Msg-id CAKFQuwa7agwXq=W+eY+52u=4HMYSviQJo=1OVB4HWwxQmmNhxQ@mail.gmail.com
обсуждение исходный текст
Ответ на Stored procedures  (Simon Connah <simon.n.connah@protonmail.com>)
Список pgsql-novice
On Sunday, August 27, 2023, Simon Connah <simon.n.connah@protonmail.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.

В списке pgsql-novice по дате отправления:

Предыдущее
От: Simon Connah
Дата:
Сообщение: Stored procedures
Следующее
От: Gurjeet Singh
Дата:
Сообщение: Re: Stored procedures