zoukankan      html  css  js  c++  java
  • Mysql 单表数据量过大移除数据

    由于单表量太大,导致性能问题

    # 1 创建表
    create table XXX_test like XXX;
    
    # 2 转移数据
    insert into XXX_test
    select * from XXX where grasping_time>='2019-01-01 00:00:00' and grasping_time<'2020-01-01 00:00:00'
    
    # 3 移除数据
    delete from XXX where grasping_time>='2019-01-01 00:00:00' and grasping_time<'2020-01-01 00:00:00'

    待处理记录 每次处理100W条

    select count(1) from t_shopping_receipt_info where grasping_time<'2018-06-01 00:00:00'
    
    
    select count(1) from t_shopping_receipt_info where grasping_time>='2018-06-01 00:00:00' and grasping_time<'2018-11-01 00:00:00'
    
    
    select count(1) from t_shopping_receipt_info where grasping_time>='2018-11-01 00:00:00' and grasping_time<'2018-12-01 00:00:00'
    
    
    select count(1) from t_shopping_receipt_info where grasping_time>='2018-12-01 00:00:00' and grasping_time<'2019-01-01 00:00:00'
  • 相关阅读:
    Redis常见数据类型
    MYSQL常见可优化场景
    算术切片
    找数组里没出现的数
    不同路径和(II)
    不同路径和
    最小路径和
    强盗抢房子
    丑数(2)
    判断子序列
  • 原文地址:https://www.cnblogs.com/eason-d/p/13219773.html
Copyright © 2011-2022 走看看