News for hackers. Stuff that matters.
Re:My £4 a month server can handle 4.2M requests a day by JJMcJ on Tuesday September 07, 2021 @06:32PM (#28450712)
Your pattern is quite powerful: get data from several sources and do the rearranging on the client (which might be a web server), instead of multiple interactions for each data item.

For SQL you can also do a stored procedure. Sometimes that works well if you are good at your DBMS's procedure language and the schema is good.

Re:My £4 a month server can handle 4.2M requests a day by spfzero on Tuesday September 07, 2021 @11:51PM (#28452820)
Though stored procs will always execute on the server that is probably already the system bottleneck.
Re:My £4 a month server can handle 4.2M requests a day by funnybeam on Wednesday September 08, 2021 @02:56AM (#28453946)
Sending multiple queries from your web server will likely put more load on the database server than using a stored procedure.

With either technique you are still pulling all the data you need from the DB but with multiple queries instead of a stored procedure you are usually pulling more data than you need with each query and then dropping any rows or fields you’re not interested in. Together with multiple calls over the network to the DB server and (often) multiple SQL connection setups this is much worse for performance on both the web and database servers

Re:My £4 a month server can handle 4.2M requests a day by bigbizisverywyz on Wednesday September 08, 2021 @08:07AM (#28455869)
>Sending multiple queries from your web server will likely put more load on the database server than using a stored procedure.

Lots of people seem to not realize that db roundtrips are expensive, and should be avoided whenever possible.

One of the best illustrations of this I've found is in Transaction Processing book by Jim Gray and Andreas Reuters where they illustrate the relative cost of getting data from CPU vs CPU cache vs RAM vs cross host query.

Re:My £4 a month server can handle 4.2M requests a day by JJMcJ on Wednesday September 08, 2021 @12:51PM (#28459728)
Except for open and writing to files, it's about the heaviest action on a backend server.