Javascript-ajax Simple Request Slow

Source: Internet
Author: User

The data table has only a few records, the query should be very fast, why the request time so long? (The local server is requested)

Look at the data query time, it's time spent here

The database only has this 10来 row of data, and ParentID also indexed, why is the query so slow?


0.001s for direct query execution on phpMyAdmin

Reply content:

The data table has only a few records, the query should be very fast, why the request time so long? (The local server is requested)

Look at the data query time, it's time spent here

The database only has this 10来 row of data, and ParentID also indexed, why is the query so slow?


0.001s for direct query execution on phpMyAdmin

Ajax URL query string, and there is nothing in data, I guess this delay is because the front end and the backend are waiting for this empty data packet, so you go directly to the Get method to try it, or you can spell a formdata in data.

Upstairs is right. I suggest that you change the JavaScript in a for loop like this:

for(var i=0;i
  
   <>

可以尝试下。

问题可能不在代码,你用127.0.0.1代替localhost试试

多测几次,看是不是偶然的?
可能是后端代码的问题,你把其他无关代码注释掉试一下?

是不是数据库出问题了,连接访问速度太慢?

1.POST请求修改为GET请求
2.select 修改为 select fileds 具体的字段,避免使用 通配符
3.desc 或者 explain下 你的SQL,看下是否用到了索引

  • 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.