LP #1061999: pt-online-schema-change errors out for large PK

Description

**Reported in Launchpad by Tianshi Wang last update 11-10-2012 21:59:05

using pt-online-schema-change version 2.1.4

pt-online-schema-change --alter "ENGINE=InnoDB" --execute D=dbname,t=mytable

The table has eight-column primary key with 126 bytes, and no other indexes. Here is the error message.

Error copying rows from `dbname`.`mytable` to `dbname`.`_mytable_new`: Error copying rows at chunk 1 of dbname.mytable because MySQL used only 40 bytes of the PRIMARY index instead of 126. See the --[no]check-plan documentation for more information.

The dry-run process completed without any errors.

Environment

None

Smart Checklist

Activity

Show:

lpjirasync January 24, 2018 at 7:01 PM

**Comment from Launchpad by: Daniel Nichter on: 11-10-2012 21:58:44

This is not a bug but the tool detecting and avoiding a potentially bad situation. There's an issue with how the tool uses indexes having > 3 columns and how MySQL does not optimize the tool's WHERE clause. It's difficult to say if it's a bug or limitation in the tool or MySQL, but the bad situation is that MySQL can scan the table (or the index). If the table is large, this can be very slow. This situation is detected when MySQL chooses the index but doesn't actually use it fully (e.g. it only uses the first 5 of 8 columns).

There are three potential solutions. One, use another --chunk-index (preferably unique and having only 1 or 2 columns). Or two: --chunk-index-columns (see the docs). Or three: examine the PTDEBUG output to see the EXPLAIN results that the tool is getting and if it looks ok to you (i.e. the estimated rows isn't huge) then use --no-check-plan to disable this check.

I don't know how much experience you have with MySQL, if not a lot, then you could pay for someone at Percona to look at this issue. Depending on what you're ultimately trying to do, there could be other solutions/alternatives.

Since this isn't a bug, I'll close this issue, but if you have further questions, please feel free to reply to this issue.

Not a Bug

Details

Assignee

Reporter

Priority

Smart Checklist

Created January 24, 2018 at 7:00 PM
Updated February 3, 2018 at 10:37 PM
Resolved January 24, 2018 at 7:01 PM