Repository navigation
fix(mssql): apply INCLUDING/EXCLUDING before per-table catalog queries - #1785
Open
George-Fam wants to merge 2 commits into
Open
George-Fam wants to merge 2 commits into
George-Fam wants to merge 2 commits into
Conversation
MSSQLSource ignored the table-spec passed to create-source, so catalog listed every user table and ran five metadata queries per table (columns, primary keys, indexes, foreign keys, extended properties) before core.clj filtered the result. INCLUDING ONLY therefore could not shorten the catalog sweep, which scales with the total table count. This restores v3 behaviour, where INCLUDING/EXCLUDING have been pushed into the MSSQL catalog SQL since 46be4a5 (2014); the v4 port has ignored table-spec since the v4 Clojure rewrite (9fb3fae).
Unit test (mssql_test.clj): stub the catalog queries and check that, with a table filter, per-table metadata is only queried for the matching tables. Fails without the previous commit. Regression test 14-including-only: an includetest database with two keep_* tables and one drop_audit table, loaded by mssql-including.load with INCLUDING ONLY TABLE NAMES LIKE 'keep%' IN SCHEMA 'inc'. Checks that only the matching tables are migrated, with their rows and the foreign key between them. Passes with v3 and v4.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thanks for pgloader. I found this while evaluating v4 for an MSSQL migration.
Problem
In v4,
MSSQLSourceignores thetable-specpassed tocreate-source, socatalogruns five metadata queries per table (columns, primary keys, indexes, foreign keys, extended properties) for every user table, andcore.cljapplies INCLUDING/EXCLUDING only afterwards. WithINCLUDING ONLY TABLE NAMES LIKE 'x'on a database with many tables, the catalog step still costs five round trips for each table in the database.The migrated tables are correct, but the cost regressed. v3 had pushed these filters into the MSSQL catalog SQL since 46be4a5; the v4 rewrite (9fb3fae) dropped it.
Fix
create-sourcenow passes(:table-filter table-spec)toMSSQLSource, andcatalogapplies it to the table list before the per-table queries. Without a filter, behaviour is unchanged.The post-filter in
core.cljstays. Both filters see the same raw table name, so the set of migrated tables is identical.Testing
test-catalog-prefilters-tables: stubs the catalog queries and checks that, with a table filter, per-table metadata is only queried for the matching tables. It fails onmainand passes with the fix.14-including-only: anincludetestdatabase with twokeep_*tables and onedrop_audittable, loaded withINCLUDING ONLY TABLE NAMES LIKE 'keep%' IN SCHEMA 'inc'. Checks that only the matching tables are migrated, with their rows and the foreign key between them. Passes with v3 and v4.make test-unit: 139 tests, 523 assertions, 0 failures. cljfmt clean.