Mysql Query consumes cpu time. help me to see how to optimize the mysql structure.

Source: Internet
Author: User
Tags subdomain
Mysql Query consumes cpu time. help me to see how to optimize this mysql structure $ sqll & nbsp ;=& nbsp; "SELECT & nbsp; * & nbsp; FROM & nbsp; 'shops' & nbsp; WHERE & nbsp; 'subdomain '& nbsp ;! = Mysql queries cpu consumption time. let's see how to optimize the mysql structure.
$ Sqll = "SELECT * FROM 'shops' WHERE 'subdomain '! = ''Order by rand () LIMIT 15 ";

Only this query is used. for subdomain queries, the mysql cpu time is very high. Sina's app requires money. I don't know how to optimize it to reduce the mysql cpu time. is it necessary to create an index? How should I create it? Why can we optimize the primary key?

Below is the structure

------ Solution --------------------
Try to create an index for the subdomain field. I don't know if I can use the index. Try it yourself.
------ Solution --------------------
You do not need to add any indexes. you can add the index fields.
------ Solution --------------------
Useful for adding an index to subdomain

The primary key automatically generates a unique index.
------ Solution --------------------
RAND () does not use this function to generate random numbers.

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.