Home Backend Development PHP Tutorial mysql查询耗cpu时间,帮小弟我看看如何优化这个mysql结构

mysql查询耗cpu时间,帮小弟我看看如何优化这个mysql结构

Jun 13, 2016 pm 12:56 PM
cpu mysql nbsp rand

mysql查询耗cpu时间,帮我看看怎么优化这个mysql结构

$sqll = "SELECT * FROM `shops` WHERE `subdomain` != '' ORDER BY RAND() LIMIT 15";
Copy after login

只有用到这个查询,对subdomain查询,这个mysql cpu时间很高,新浪的app这个要钱的,不知道怎么优化可以减少mysql cpu时间, 是不是要建个索引啥的? 应该怎么建?还有主键是干嘛的 可以优化吗?

下面是结构


------解决方案--------------------
给 subdomain 字段建个索引试试,不知道能不能用到索引。自己试试看。
------解决方案--------------------
没必要都添加索引,能用到索引的字段添加就可以了。
------解决方案--------------------
subdomain 加索引有用

建主键   会自动生成唯一索引。
------解决方案--------------------
RAND() 不用这个函数 随便程序生成几个随机数
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

144-core, 3D-stacked SRAM: Fujitsu details next-generation data center processor MONAKA 144-core, 3D-stacked SRAM: Fujitsu details next-generation data center processor MONAKA Jul 29, 2024 am 11:40 AM

According to news from this website on July 28, foreign media TechRader reported that Fujitsu introduced in detail the FUJITSU-MONAKA (hereinafter referred to as MONAKA) processor planned to be shipped in 2027. MONAKACPU is based on the "cloud native 3D many-core" architecture and adopts the Arm instruction set. It is oriented to the data center, edge and telecommunications fields. It is suitable for AI computing and can realize mainframe-level RAS1. Fujitsu said that MONAKA will achieve a leap in energy efficiency and performance: thanks to technologies such as ultra-low voltage (ULV) technology, the CPU can achieve 2 times the energy efficiency of competing products in 2027, and cooling does not require water cooling; in addition, the application performance of the processor It can also reach twice as much as your opponent. In terms of instructions, MONAKA is equipped with vector

Leak reveals key specs of Intel Arrow Lake-U, -H, -HX and -S Leak reveals key specs of Intel Arrow Lake-U, -H, -HX and -S Jun 15, 2024 pm 09:49 PM

IntelArrowLakeisexpectedtobebasedonthesameprocessorarchitectureasLunarLake,meaningthatIntel'sbrandnewLionCoveperformancecoreswillbecombinedwiththeeconomicalSkymontefficiencycores.WhileLunarLakeisonlyavailableasava

AM4 refuses to die, news says AMD will launch Ryzen 9 5900XT/7 5800XT: clocked at up to 4.8GHz AM4 refuses to die, news says AMD will launch Ryzen 9 5900XT/7 5800XT: clocked at up to 4.8GHz Jun 05, 2024 pm 09:43 PM

According to news from this website on June 1st, the source @CodeCommando tweeted today, sharing some screenshots of AMD’s upcoming presentation documents at the Computex2024 event. The content of the tweet was “AM4 will never die”, and the accompanying picture showed two new Ryzen5000XT series processors. The screenshots show the following two products: Ryzen 95900 Ryzen75800XT It is a faster variant of AMD's existing Ryzen75800X processor. Both processors are clocked up to 4.8G

How to optimize MySQL query performance in PHP? How to optimize MySQL query performance in PHP? Jun 03, 2024 pm 08:11 PM

MySQL query performance can be optimized by building indexes that reduce lookup time from linear complexity to logarithmic complexity. Use PreparedStatements to prevent SQL injection and improve query performance. Limit query results and reduce the amount of data processed by the server. Optimize join queries, including using appropriate join types, creating indexes, and considering using subqueries. Analyze queries to identify bottlenecks; use caching to reduce database load; optimize PHP code to minimize overhead.

How to create a MySQL table using PHP? How to create a MySQL table using PHP? Jun 04, 2024 pm 01:57 PM

Creating a MySQL table using PHP requires the following steps: Connect to the database. Create the database if it does not exist. Select a database. Create table. Execute the query. Close the connection.

How to fix mysql_native_password not loaded errors on MySQL 8.4 How to fix mysql_native_password not loaded errors on MySQL 8.4 Dec 09, 2024 am 11:42 AM

One of the major changes introduced in MySQL 8.4 (the latest LTS release as of 2024) is that the "MySQL Native Password" plugin is no longer enabled by default. Further, MySQL 9.0 removes this plugin completely. This change affects PHP and other app

Intel CPU size and core scheduling issues, CPU size and core optimization settings above 12 generations Intel CPU size and core scheduling issues, CPU size and core optimization settings above 12 generations Jun 19, 2024 am 01:42 AM

Inteli5-12600 and above CPUs, i5-13400 and above CPUs have P-Core performance cores (large cores) and E-Core energy efficiency cores (small cores). Due to the scheduling problem of "big and small cores", some games may drop frames. , lag, not as good as the old CPU before. In fact, the system thinks that to cope with the current scene, the younger one can handle it, and there is no need to dispatch the older one, so the older core has been resting and not working. The editor below will teach you how to solve this problem. Create a new text document on the desktop, copy the following content, save it as 1.reg, and then right-click to merge. WindowsRegistryEditorVersion5.00[HKEY_LOCAL_MACHINE\SY

Intel confirms LGA9324 Oak Stream-AP platform supports Diamond Rapids Xeon processors Intel confirms LGA9324 Oak Stream-AP platform supports Diamond Rapids Xeon processors Aug 22, 2024 am 11:16 AM

According to news from this site on August 22, X platform user 포시포시 (@harukaze5719) noticed that Intel listed two adapter boards suitable for LGA9324-OKS-AP platform power supply testing on its official website DESIGN-iNTOOLSstore. ▲BLU version adapter board, in addition to RED version Intel wrote in the description of these two products that the LGA9324-OKS-APOakStream platform supports DiamondRapids, which positively confirms the next-generation Xeon performance core after Xeon 6 "GraniteRapids" The existence of processors and corresponding platforms. Current information on DiamondRapids processors and OakStream platforms

See all articles