Habtm relation size calculation fix 4 0 stable

HABTM should not include new records as part of #count_records as new records are already counted.

This addresses #14914 for the 4-0-stable branch, and is a different approach to #14969 which addresses the same issue.

cc @rafaelfranca @bigxiang