Home  >  Article  >  Backend Development  >  Do multiple Ajax requests consume more server-side performance, or does server-side Mysql Join consume more performance?

Do multiple Ajax requests consume more server-side performance, or does server-side Mysql Join consume more performance?

WBOY
WBOYOriginal
2016-10-23 00:00:031108browse

There is such a need:

There are multiple tables on the server, and they all have associated keys content-id.

The previous approach was:

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.

But some colleagues said that this consumes too much performance and should be changed to this:

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?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn