When dropping a partition on InnoDB table does mysql flush pages in the whole table or only in a partition to be dropped?

dba.stackexchange https://dba.stackexchange.com/questions/282750

문제

When issuing ALTER TABLE .. DROP PARTITION p1 mysql have to flush pages to disk. My question is: does mysql flush pages in the whole table (in each partition) or only in a partition to be dropped? MySQL server 5.7

table partition exp. is: PARTITION BY RANGE (UNIX_TIMESTAMP(dt))

도움이 되었습니까?

해결책

According to the MySQL 5.7 Documentation under the subheading Affected DDL statements, here is what says about Locking for DDL on Partitioned Tables:

CREATE VIEW does not cause any locks.

ALTER TABLE ... EXCHANGE PARTITION prunes locks; only the exchanged table and the exchanged partition are locked.

ALTER TABLE ... TRUNCATE PARTITION prunes locks; only the partitions to be emptied are locked.

In addition, ALTER TABLE statements take metadata locks on the table level.

As far as I can see in that page, it locks the table's metadata. There is nothing here suggesting that all the .ibd files of the other partitions need to be flushed. It would affect only those files involved.

In your case, it would involve the following steps:

  • Acquire metadata lock on the .par file of the partitioned table
  • Update list of partitions in the .par file
  • Remove locks of .ibd you are going to drop
  • Unlock the .par file

NOTE : Dropping a partition is DDL not DML.

DIRECT ANSWER TO YOUR QUESTION

Only partition to be dropped

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 dba.stackexchange
scroll top