Improve schema reload performance by pre-filtering joined rows. (#11043)
Improve schema reload performance by pre-filtering joined rows. (#11043)

When reloading the database schema, a query to fetch table information and tablespace information is executed. This query can take a long time when run on a mysql instance with many tables across many databases.

We notice the impact of this query during database setup in our CI environments, as this query is executed on each DDL statement (and thus gets incrementally slower the more tables are being created).

Performance of this query was improved before in https://github.com/vitessio/vitess/pull/9632 by pre-filtering the rows of the `information_schema.innodb_sys_tablespaces` before joining them to rows from `information_schema.tables`, but that change was accidentally reverted in https://github.com/vitessio/vitess/pull/10703.

This brings back the pre-filtering.

Signed-off-by: Arthur Schreiber <ab1625150cb990bb0390212baac38b830e689332@github.com>

Signed-off-by: Arthur Schreiber <ab1625150cb990bb0390212baac38b830e689332@github.com>
vitessio/vitess,vitessio/vitess,vitessio/vitess,vitessio/vitess,mahak/vitess,mahak/vitess,vitessio/vitess,mahak/vitess,vitessio/vitess,mahak/vitess,mahak/vitess,vitessio/vitess,mahak/vitess,mahak/vitess,vitessio/vitess,mahak/vitess