MySQL - OPTIMIZE TABLE for partitions
From the MySQL Manual:


  Some MySQL storage engines, including InnoDB, do not support
  per-partition optimization; in these cases, ALTER TABLE ... OPTIMIZE
  PARTITION rebuilds the entire table.


There is a reason to optimize separately each partition, in order to avoid locking and performance issues. However, if you are using Innodb, you will get the following warning:

Table does not support optimize on partitions. All partitions will be rebuilt and analyzed


Which basically makes the OPTIMIZE PARTITION syntax useless. Also, if you only have 2 partitions (p0 and p1), you are basically executing OPTIMIZE TABLE.

My questions is why you are running optimize to start with and if it is justified? You should also add the MySQL version and engine used. In any case, you are probably executing the first option implicitly or explicitly.