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

WBOY
Release: 2016-10-23 00:00:03
Original
1068 people have browsed it

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:

select * from tableA join tableB on tableB.id = tableA.id ...(可能有多个JOIN)... where id = 5;
Copy after login

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:

select * from tableA where id = 5; select * from tableB where id = 5; select * from tableC where id = 5;
Copy after login

Which solution is better?

Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!