Adding an index to a table field saves me 8S.

Source: Internet
Author: User
Tags create index

Whether it is to solve their own problems or others to help me solve, I have summed it up to write down the lessons learned, this will be very useful in the future.

This is a previous SQL statement each query will be used for approximately 8S clock:

Select COUNT (1) as "Count"
From T_ims_calllog l
INNER JOIN T_tms_user U
On L.deviceno = u.user_id
Left JOIN T_tms_customer_data C
On L.calleeno = C.mobile
where flag = 1
and callidnum =-1
And Recordpath is not NULL
and Calleeno = ' 18915509192 '
and L.callbegin!= L.callend

Originally I thought it was the T_ims_calllog table and the T_tms_user, t_tms_customer_data links caused by the timeout, in fact, they three chain link cost about 9s clock. Then invited a master to come over, he said should give Calleeno field index. And then you add the index, and the index adds this:

Create index t_ims_calllog_test on T_ims_calllog <CALLEENO> nologging;

Query the above statement again, the miracle appeared time consuming only use 0.015s, rub ...



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.