Skip to content

Conversation

@buehmann
Copy link
Contributor

The following caught my eye when running connection.disable_referential_integrity { ... } in a Rails console (using v4.2.18 of the adapter):

...
  SQL (99.4ms)  ALTER TABLE [dbo].[accounts] CHECK CONSTRAINT ALL
  SQL (80.5ms)  ALTER TABLE [dbo].[accounts] CHECK CONSTRAINT ALL
  SQL (85.7ms)  ALTER TABLE [dbo].[accounts] CHECK CONSTRAINT ALL
  SQL (107.9ms)  ALTER TABLE [dbo].[debt_claim_postings] CHECK CONSTRAINT ALL
  SQL (83.6ms)  ALTER TABLE [dbo].[debt_claim_postings] CHECK CONSTRAINT ALL
  SQL (86.2ms)  ALTER TABLE [dbo].[debt_claim_postings] CHECK CONSTRAINT ALL
  SQL (87.2ms)  ALTER TABLE [dbo].[debt_claim_postings] CHECK CONSTRAINT ALL
  SQL (88.5ms)  ALTER TABLE [dbo].[debt_claim_postings] CHECK CONSTRAINT ALL
  SQL (82.9ms)  ALTER TABLE [dbo].[debt_claim_postings] CHECK CONSTRAINT ALL
  SQL (84.8ms)  ALTER TABLE [dbo].[tx_pins] CHECK CONSTRAINT ALL
...

Apparently duplicates are not eliminated when determining the set of tables with foreign key constraints.

In our case the adapter emitted 2 * 256 ALTER TABLE ... (NO)CHECK CONSTRAINT ALL statements instead of the sufficient 2 * 167.

It would be lovely to see this fix in the 4.2 line as well.

@thomasfedb
Copy link

@metaskills this PR seems reasonable. Could it be merged?

@metaskills
Copy link
Member

Your call @thomasfedb but yes.

Copy link
Member

@wpolicarpo wpolicarpo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution @buehmann.

@wpolicarpo wpolicarpo merged commit bfc887b into rails-sqlserver:master Dec 17, 2018
@buehmann buehmann deleted the perf/uniq-tables-with-ref-integr branch December 19, 2018 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants