public inbox for [email protected]
help / color / mirror / Atom feedRe: Stored procedures or raw queries
2+ messages / 2 participants
[nested] [flat]
* Re: Stored procedures or raw queries
@ 2025-08-06 13:16 Philip Semanchuk <[email protected]>
2025-08-06 13:36 ` Re: Stored procedures or raw queries Simon Connah <[email protected]>
0 siblings, 1 reply; 2+ messages in thread
From: Philip Semanchuk @ 2025-08-06 13:16 UTC (permalink / raw)
To: Simon Connah <[email protected]>; +Cc: [email protected]
> On Aug 6, 2025, at 8:03 AM, Simon Connah <[email protected]> wrote:
>
> 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.
If your only concern is performance, then using stored procedures might be overoptimizing. It’s true that they cut down on overhead, but that overhead might be meaningless in terms of overall performance. For instance, if you have low latency between your web server and database server, and your typical query takes 5-6 seconds to execute, then most of your users’ wait time is due to execution time, not to communication between servers. Stored procedures won’t help you much.
If you’re building a simple web site, I suggest starting with what seems simplest for you (which sounds like raw SQL from your description) and then addressing performance problems as they arise. Stored procedures are one tool in the performance toolbox.
good luck
Philip
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Stored procedures or raw queries
2025-08-06 13:16 Re: Stored procedures or raw queries Philip Semanchuk <[email protected]>
@ 2025-08-06 13:36 ` Simon Connah <[email protected]>
0 siblings, 0 replies; 2+ messages in thread
From: Simon Connah @ 2025-08-06 13:36 UTC (permalink / raw)
To: Philip Semanchuk <[email protected]>; +Cc: [email protected]
Thank you all for your help. It is much appreciated. I'll have a play
around and see how things work out.
Simon.
On Wed, 6 Aug 2025 at 14:17, Philip Semanchuk
<[email protected]> wrote:
>
>
>
> > On Aug 6, 2025, at 8:03 AM, Simon Connah <[email protected]> wrote:
> >
> > 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.
>
> If your only concern is performance, then using stored procedures might be overoptimizing. It’s true that they cut down on overhead, but that overhead might be meaningless in terms of overall performance. For instance, if you have low latency between your web server and database server, and your typical query takes 5-6 seconds to execute, then most of your users’ wait time is due to execution time, not to communication between servers. Stored procedures won’t help you much.
>
> If you’re building a simple web site, I suggest starting with what seems simplest for you (which sounds like raw SQL from your description) and then addressing performance problems as they arise. Stored procedures are one tool in the performance toolbox.
>
> good luck
> Philip
>
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2025-08-06 13:36 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-08-06 13:16 Re: Stored procedures or raw queries Philip Semanchuk <[email protected]>
2025-08-06 13:36 ` Simon Connah <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox