Is it more expensive for multiple AJAX requests to consume server-side performance, or is server-side MySQL join more cost-performance?

Source: Internet
Author: User
There is such a requirement:

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

The previous practice was to:

The front end sends an AJAX request, back-end MySQL according to Content-id, will be a number of tables to do join query, PHP output JSON, and then the front end of the JSON parsing rendering.

But some colleagues say this is too much to consume performance, to change to this:

The front end instead makes multiple AJAX requests, the backend queries each table, each AJAX request corresponds to only one table, no more JSON is join,php output, and then the JSON is parsed and rendered by the front end.

Supplemental Table structure:

Queries for all tables are very simple:
The previous method, just one query:

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

To change the method, the previous method has how many tables, this method has how many AJAX requests, there are many times query:

select * from tableA where id = 5;select * from tableB where id = 5;select * from tableC where id = 5;

Which is the better option, please?

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.