随笔分类 -  数据库

摘要:select right(aa.c, length(aa.c) - locate(',', aa.c))from ( select group_concat(id) as c from tb_xl_route group by shop_id, type, route having count(1) 阅读全文
posted @ 2022-01-18 17:45 wanhua.wu
摘要:POST /index_name/_cache/clear 清理掉相关聚合查询索引的缓存 阅读全文
posted @ 2020-08-06 20:22 wanhua.wu
摘要:SHOW ENGINE INNODB STATUS 阅读全文
posted @ 2020-08-06 18:44 wanhua.wu
摘要:clustername: bshop index: mlanguage_test type: mlanguage_type直接创建索引即可,不用创建type,创建索引之后会有一个自动的type与其对应 PUT mlanguage_test 设置权限: kibana - Management - In 阅读全文
posted @ 2020-06-05 16:36 wanhua.wu
摘要:查询邮箱:info@whistlingwoods.net SELECT CREATE_TIME FROM t_mail_send_extend46 WHERE USER_ID = 'e4cf948cad9f40be8a1ccbc7eb8666ee' AND LOCATE('info@whistlin 阅读全文
posted @ 2020-06-03 13:44 wanhua.wu
摘要:需求:获取指定用户下某个邮箱最近一次发送时间 场景: CREATE_TIME, USER_ID 已经添加索引, ADDRESS是text字段无法添加索引。 原语句:(max导致全表扫描!!!) SELECT MAX(CREATE_TIME) AS MAX0 FROM t_mail_send_exte 阅读全文
posted @ 2020-05-19 15:19 wanhua.wu
摘要:需求: 有一个表t_mail_send_extend, 主键唯一索引是id,因为数据量达到了500多万,占用磁盘空间62GB,现在考虑使用mycat进行分表,分表之前需要将数据提前从mycql查询然后插入到mycat中的分表中,在查询过程中会遇到查询效率问题,越往后越慢 一般的查询:(通过控制lim 阅读全文
posted @ 2020-05-11 17:14 wanhua.wu
摘要:原始语句: INSERT INTO mail_send ( createTime, updateTime, flag, accountId, messageID, sender, senderName, fromer, replyTo, toer, ccer, bccer, SUBJECT, tex 阅读全文
posted @ 2020-04-30 14:47 wanhua.wu
摘要:-- 查询死锁 show open tables where In_use > 0 -- 查找进程然后kill show PROCESSLIST; 阅读全文
posted @ 2019-12-19 10:44 wanhua.wu
摘要:show innodbstatus\G; show variables like '%timeout%'; show status like '%lock%'; show status like 'Table%'; Table_locks_immediate 指的是能够立即获得表级锁的次数 Tabl 阅读全文
posted @ 2019-07-18 14:30 wanhua.wu
摘要:1,排查大文本字段查询 text,longtext这些类型的大文本字段应该单独查询,只有用到的时候多查询一次 例子:营销邮件列表查询,里面含有大文本字段content, receivers,查询时默认使用了select * ,本来40毫秒的查询用了额3.8秒 2,用LOCATE(substr,str 阅读全文
posted @ 2018-10-15 19:21 wanhua.wu
摘要:select* ,(length(message)-length('t2')) as rn from total where message like '%t2%' order by rn; 阅读全文
posted @ 2018-08-06 21:01 wanhua.wu
摘要:1,DataX 是一个异构数据源离线同步工具,致力于实现包括关系型数据库(MySQL、Oracle等)、HDFS、Hive、ODPS、HBase、FTP等各种异构数据源之间稳定高效的数据同步功能。 https://github.com/alibaba/DataX https://github.com 阅读全文
posted @ 2018-08-02 10:39 wanhua.wu
摘要:当redis中key失效时进行回调操作 阅读全文
posted @ 2018-07-25 20:30 wanhua.wu
摘要:参考:https://stackoverflow.com/questions/8352115/mysql-list-in-list 1,使用IN方法 注:有bug(条件:01,02,03; 数据库:01,02可以匹配, 但是02,03无法匹配) 2,使用find_in_set 阅读全文
posted @ 2018-07-23 11:01 wanhua.wu
摘要:ES笔记(有道云): http://note.youdao.com/noteshare?id=2a9e896be3fd997d29a868bd17d1241a&sub=57DBAF694BBB459B89EE19D7FE731FD7 优化聚合查询: https://www.elastic.co/gu 阅读全文
posted @ 2018-07-16 10:03 wanhua.wu
摘要:MongoDB客户端:1,NoSQL Manager for MongoDB2,Robomongo(推荐,好多教程上的语句可以直接使用)不同的客户端执行语句有差异 参考:https://docs.mongodb.com/manual/reference/operator/aggregation/co 阅读全文
posted @ 2018-07-14 15:33 wanhua.wu
摘要:参考:http://m635674608.iteye.com/blog/2387781 阅读全文
posted @ 2018-07-09 13:43 wanhua.wu
摘要:http://lobert.iteye.com/blog/1604122 阅读全文
posted @ 2018-06-27 09:11 wanhua.wu
摘要:UPDATE scrm.t_contacts t SET t.MAIN_USER_ID = ( SELECT IF ( u.`PARENT_ID` = '0', u.`ID`, u.`PARENT_ID` ) MAIN_USER_ID FROM `user-center`.tb_user u ... 阅读全文
posted @ 2018-06-26 14:28 wanhua.wu