› MySQL 5.5 Community Server
› MySQL 5.6 Community Server
› Percona Configuration Wizard
› XtraBackup 搭建主从复制
Great Sites on MySQL
› Percona
› MySQL Performance Blog
› Severalnines
推荐管理工具
› Sequel Pro
› phpMyAdmin
推荐书目
› MySQL Cookbook
MySQL 相关项目
› MariaDB
› Drizzle
参考文档
› http://mysql-python.sourceforge.net/MySQLdb.html
hackingwu
V2EX  ›  MySQL

要使用 mysql 分区表吗?

  •  
  •   hackingwu ·
    hackingwu · Oct 16, 2020 · 3821 views
    This topic created in 2173 days ago, the information mentioned may be changed or developed.

    我有一张表,一天大概生成 5w 条记录,历史数据要求保留 1 年。我在想要做分区表吗? 索引有(id), (a_id), (b_id, time_create), (c_id, time_create) 如果分区的条件用 time_create 做 range, 那 id 和 a_id 的查询 其实是会去每个分区都查一遍吧。大家觉得要做分区表吗

    5 replies  •  2020-10-16 16:08:15 +08:00
    zoharSoul
        1
    zoharSoul  
       Oct 16, 2020
    分区表是必须要带上唯一索引的.
    msaionyc
        2
    msaionyc  
       Oct 16, 2020
    实在不行,每天 23:59 建个次日的表,每天写不同的表
    9LCRwvU14033RHJo
        3
    9LCRwvU14033RHJo  
       Oct 16, 2020   ❤️ 1
    5 * 365 也才不到 2000 万条吧。
    huntcool001
        4
    huntcool001  
       Oct 16, 2020
    没必要了. 分区表现在唯一的作用就是,你整体删除的时候,会快一些. 比如说按月分,那么你分 12 个 partition, 每次你删一年前过期的那一个区,会很快.

    所以结论就是别分区.
    hackingwu
        5
    hackingwu  
    OP
       Oct 16, 2020
    @huntcool001 是的 我也是这么想的,那就是要运维定期去归档数据。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2789 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 14:43 · PVG 22:43 · LAX 07:43 · JFK 10:43
    ♥ Do have faith in what you're doing.