Is it safe to run mysqloptimize on a 5.7 PXC cluster?

I have searched the forum, but all Q&A related to this are very old (some dating back to 2012-2013).

So, ¿is it safe to run mysqloptimize -o databasename on a PXC 5.7 cluster on 2023?

Hi @nublaii,

I’d not run “optimize table” in PXC directly. We can do that two ways:

  1. Manual RSU to perform null alter. Refer this blogpost for the explanation.
  2. pt-osc (This is my favourite and straightforward)
pt-online-schema-change --execute --alter "ENGINE=InnoDB" 

Let me know how would you go about this. BTW can you enlighten me, what command / script is this " mysqloptimize"?

Thanks,
K

Hi there

It is just a symlink to mysqlcheck, it comes from the package percona-xtradb-cluster-client (using ubuntu).

lrwxrwxrwx 1 root root 10 May 18 20:28 /usr/bin/mysqloptimize -> mysqlcheck

1 Like

@nublaii,
Can you explain why you want to run OPTIMIZE TABLE on all tables in your PXC? If you are trying to reclaim disk space, go with @kedarpercona solution above. If you want to simply update the index statistics, you can use ANALYZE TABLE at any time.

1 Like