Solutions to Mysql index performance optimization problems

Solutions to Mysql index performance optimization problems

The optimization created by MySQL is to add indexes, but sometimes you may encounter situations where adding indexes cannot achieve the desired effect.

After adding so, the search still fails for all data. The reason is sql

EXPLAIN SELECT
      cs.sid,
      -- c.courseFrontTitle,
      -- c.imgBig,
      cs.studyStatus,
      coi.fee,
      -- act.PROC_INST_ID_ AS processId,
      cs.createDTM,
      cs.payStatus,
      cs.isCompleted,
      cs.saleChannel,
cs.isDelete
    FROM
      Biz_CourseStudy cs

    LEFT JOIN Biz_CourseOrderItem coi ON cs.sid = coi.CourseStudyID 
    
    WHERE
      cs.studentID = 00001 and cs.payStatus not in(0)

By looking at the index, the reason is that sid is bigint and the type of CourseStudyID is varchar. The reason is here. After changing the type to bigint, the query speed is instantly improved.

I have encountered such a situation. After analyzing the extra, I found that the speed was OK without order by 0.6s and added order by 6s.

The solution is to create an index for the order by. Here my order by is two fields.

order by endTime desc ,isDelete desc

Create a joint index for ab, index_a_b

SELECT xxx FROM manage a FORCE INDEX(index_a_b)
LEFT JOIN f_name f ON f.user_id = a.user_id
ORDER BY a.endTime desc,a.isDelete desc

At this time, looking at the performance, Using filesort has disappeared

The speed directly becomes 0.6s

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • MySQL performance optimization index pushdown
  • MySQL performance optimization: how to use indexes efficiently and correctly
  • Mysql performance optimization case - covering index sharing
  • Mysql performance optimization case study - covering index and SQL_NO_CACHE
  • MySQL performance optimization index optimization
  • The usage strategy and optimization behind MySQL indexes (high-performance index strategy)
  • MySQL uses indexes to optimize performance

<<:  Nginx compiled nginx - add new module

>>:  Detailed process of configuring Https certificate under Nginx

Recommend

Detailed explanation of how to use the mysql backup script mysqldump

This article shares the MySQL backup script for y...

mysql charset=utf8 do you really understand what it means

1. Let's look at a table creation statement f...

jQuery implements accordion small case

This article shares the specific code of jQuery t...

Detailed introduction to linux host name configuration

Table of contents 1. Configure Linux hostname Con...

Write a dynamic clock on a web page in HTML

Use HTML to write a dynamic web clock. The code i...

Introduction to using data URI scheme to embed images in web pages

The data URI scheme allows us to include data in a...

Mini Program to implement Token generation and verification

Table of contents process Demo Mini Program Backe...

The pitfall record of case when judging NULL value in MySQL

Table of contents Preface Mysql case when syntax:...

Our thoughts on the UI engineer career

I have been depressed for a long time, why? Some t...