Home > Article > Backend Development > Do multiple Ajax requests consume more server-side performance, or does server-side Mysql Join consume more performance?
There is such a need:
There are multiple tables on the server, and they all have associated keys content-id.
The front-end issues an Ajax request, and the back-end mysql performs a join query on multiple tables based on the content-id. PHP outputs json, and then the front-end parses and renders the json.
The front-end instead issues multiple Ajax requests, and the back-end queries each table. Each ajax request only corresponds to one table, and joins are no longer performed. PHP outputs multiple json, and then the front-end parses and renders the json.
Supplementary table structure:
The query of all tables is very simple:
The previous method is just one query:
<code>select * from tableA join tableB on tableB.id = tableA.id ...(可能有多个JOIN)... where id = 5;</code>
The method to be changed to, as many tables as the previous method, this method will have as many Ajax requests, and as many queries as there will be:
<code>select * from tableA where id = 5; select * from tableB where id = 5; select * from tableC where id = 5;</code>
Which solution is better?