首頁 資料庫 mysql教程 MySQl在開發和生產不同環境下的索引對比

MySQl在開發和生產不同環境下的索引對比

Jul 19, 2017 pm 05:21 PM
mysql 環境 索引

--1.建立索引資訊表
create table `t_index_update` (
  `table_name` varchar(20) COLLATE gbk_bin DEFAULT NULL,
  `index_name` varchar(20) COLLATE gbk_bin, DEULTTor
  `index_cols` varchar(100) COLLATE gbk_bin DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=gbk COLLATE=gbk_bin;
--2.插入線下索引資訊表
insert into t_index_update(
select  
table_name,
index_name,
group_concat(distinct concat('`', column_name, '`') order by seq_in_index asc separator ', ') as index_cols
from information_sche.STATIST
where  table_schema= 'elk'
and column_name<>'seq_id'
and index_name<>'primary'
group by table_name, index_name##order# by table_name asc, index_name asc;
--3.同步線下索引資訊表到線上
--4.建立刪除和修改過的索引的刪除語句
select concat('alter table `',a.table_name,' ` drop index ',a.index_name,';')
from
(
     select  
     table_name,
    `') order by seq_in_index asc separator ', ') as index_cols
     from information_schema.STATISTICS
     where  table_schema= ” _name<>' primary'
     group by table_name, index_name
#) a
left join t_index_update b on b.table_name and b.index_name=a.index_name and b.index_cols=a.index_cols#>#where b.index_ ;
--5.建構新加索引的的新加語句
select concat('alter table `',a.table_name,'` add index ',a.index_name,'(',a.index_cols ,');')
from t_index_update a
left join (
     select  
     table_name,
    by seq_in_index asc separator ', ') as index_cols
     from information_schema.STATISTICS
     where  table_schema= 'elk'
&lt_lt  and coop; gt;'primary'
     group by table_name, index_name
) b   on b.table_name and b.index_name=a.index_name and b.index_cols=a.index_cols
where b.index_name is null;





#

以上是MySQl在開發和生產不同環境下的索引對比的詳細內容。更多資訊請關注PHP中文網其他相關文章!

本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱門文章

倉庫:如何復興隊友
3 週前 By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒險:如何獲得巨型種子
3 週前 By 尊渡假赌尊渡假赌尊渡假赌
兩個點博物館:所有展覽以及在哪裡可以找到它們
3 週前 By 尊渡假赌尊渡假赌尊渡假赌

熱門文章

倉庫:如何復興隊友
3 週前 By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒險:如何獲得巨型種子
3 週前 By 尊渡假赌尊渡假赌尊渡假赌
兩個點博物館:所有展覽以及在哪裡可以找到它們
3 週前 By 尊渡假赌尊渡假赌尊渡假赌

熱門文章標籤

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

PHP 的大數據結構處理技巧 PHP 的大數據結構處理技巧 May 08, 2024 am 10:24 AM

PHP 的大數據結構處理技巧

如何優化 PHP 中的 MySQL 查詢效能? 如何優化 PHP 中的 MySQL 查詢效能? Jun 03, 2024 pm 08:11 PM

如何優化 PHP 中的 MySQL 查詢效能?

如何在 PHP 中使用 MySQL 備份和還原? 如何在 PHP 中使用 MySQL 備份和還原? Jun 03, 2024 pm 12:19 PM

如何在 PHP 中使用 MySQL 備份和還原?

Java 枚舉類型在資料庫中的應用場景有哪些? Java 枚舉類型在資料庫中的應用場景有哪些? May 05, 2024 am 09:06 AM

Java 枚舉類型在資料庫中的應用場景有哪些?

如何使用 PHP 插入資料到 MySQL 表? 如何使用 PHP 插入資料到 MySQL 表? Jun 02, 2024 pm 02:26 PM

如何使用 PHP 插入資料到 MySQL 表?

如何修復 MySQL 8.4 上的 mysql_native_password 未載入錯誤 如何修復 MySQL 8.4 上的 mysql_native_password 未載入錯誤 Dec 09, 2024 am 11:42 AM

如何修復 MySQL 8.4 上的 mysql_native_password 未載入錯誤

如何在 PHP 中使用 MySQL 預存程序? 如何在 PHP 中使用 MySQL 預存程序? Jun 02, 2024 pm 02:13 PM

如何在 PHP 中使用 MySQL 預存程序?

PHP數組分頁的效能最佳化策略 PHP數組分頁的效能最佳化策略 May 02, 2024 am 09:27 AM

PHP數組分頁的效能最佳化策略

See all articles