Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

match mysql fk name generation #7711

Merged
merged 19 commits into from
Apr 9, 2024
Merged

match mysql fk name generation #7711

merged 19 commits into from
Apr 9, 2024

Conversation

jycor
Copy link
Contributor

@jycor jycor commented Apr 8, 2024

This PR removes logic where we would use a consistent hash to create foreign key names, when one isn't explicitly provided.
Instead, we use logic in GMS to generate a name with the template "<tbl_name>_ibfk_<num>", which matches MySQL behavior.

As a result, we now allow multiple foreign keys over the same sets of columns (as long as the names are different).

companion pr:
dolthub/go-mysql-server#2438

fixes:
#7650

@coffeegoddd
Copy link
Contributor

@jycor DOLT

comparing_percentages
100.000000 to 100.000000
version result total
c48d7a7 ok 5937457
version total_tests
c48d7a7 5937457
correctness_percentage
100.0

@coffeegoddd
Copy link
Contributor

@coffeegoddd DOLT

comparing_percentages
100.000000 to 100.000000
version result total
e1ef2eb ok 5937457
version total_tests
e1ef2eb 5937457
correctness_percentage
100.0

@coffeegoddd
Copy link
Contributor

@jycor DOLT

comparing_percentages
100.000000 to 100.000000
version result total
118158c ok 5937457
version total_tests
118158c 5937457
correctness_percentage
100.0

Copy link
Contributor

@fulghum fulghum left a comment

Choose a reason for hiding this comment

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

Looks good!

It's a bummer to lose the ability for two branches to both add an FK constraint or secondary index to the same table and merge them back cleanly – that is a cool trick. I think being MySQL compatible ultimately wins out here though, especially since we are giving customers a new statement to easily rename a constraint, and since customers can explicitly specify constraint names to get around the merge conflict issue.

We may eventually want to support both modes, but that's adding complexity for users to deal with, so I'd hold off on that until we know it's definitely a customer problem we need to work on.

Tagging @zachmu on this one, since he may have an opinion on the tradeoff between fully matching MySQL's behavior and keeping the deterministic fk / secondary index naming. Since the customer isn't blocked on this currently, let's give Zach a day to share an opinion, just in case he sees another problem this could cause that we aren't seeing.

Copy link
Member

@zachmu zachmu left a comment

Choose a reason for hiding this comment

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

LGTM, see comments on GMS change

Copy link
Member

@zachmu zachmu left a comment

Choose a reason for hiding this comment

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

But write tests of merge logic (can skip for now)

If two sides of the merge declare the same fk name with a different definition, that should be a schema conflict.

@coffeegoddd
Copy link
Contributor

@jycor DOLT

comparing_percentages
100.000000 to 100.000000
version result total
bfd7282 ok 5937457
version total_tests
bfd7282 5937457
correctness_percentage
100.0

@jycor jycor merged commit d2df433 into main Apr 9, 2024
20 checks passed
@jycor jycor deleted the james/fks branch April 9, 2024 23:27
Copy link

@coffeegoddd DOLT

test_name detail row_cnt sorted mysql_time sql_mult cli_mult
batching LOAD DATA 10000 1 0.07 1
batching batch sql 10000 1 0.1 1.4
batching by line sql 10000 1 0.09 1.67
blob 1 blob 200000 1 0.94 3.77 4.23
blob 2 blobs 200000 1 0.89 4.96 5.4
blob no blob 200000 1 0.97 1.9 2.14
col type datetime 200000 1 0.84 2.5 2.73
col type varchar 200000 1 0.7 2.93 3
config width 2 cols 200000 1 0.77 2.51 2.31
config width 32 cols 200000 1 1.9 1.71 2.53
config width 8 cols 200000 1 0.99 2.09 2.32
pk type float 200000 1 0.89 1.93 2.02
pk type int 200000 1 0.81 2.09 2.2
pk type varchar 200000 1 1.63 1.37 1.39
row count 1.6mm 1600000 1 5.73 2.44 2.53
row count 400k 400000 1 1.44 2.38 2.5
row count 800k 800000 1 2.88 2.39 2.49
secondary index four index 200000 1 3.63 1.25 1.07
secondary index no secondary 200000 1 0.92 2.01 2.17
secondary index one index 200000 1 1.17 2.04 2.13
secondary index two index 200000 1 2.05 1.53 1.47
sorting shuffled 1mm 1000000 0 4.99 2.5 2.67
sorting sorted 1mm 1000000 1 5.08 2.45 2.61

Copy link

@coffeegoddd DOLT

name detail mean_mult
dolt_blame_basic system table 1.25
dolt_blame_commit_filter system table 3.25
dolt_commit_ancestors_commit_filter system table 0.84
dolt_commits_commit_filter system table 0.91
dolt_diff_log_join_from_commit system table 2.01
dolt_diff_log_join_to_commit system table 2.06
dolt_diff_table_from_commit_filter system table 1.13
dolt_diff_table_to_commit_filter system table 1.14
dolt_diffs_commit_filter system table 1
dolt_history_commit_filter system table 1.37
dolt_log_commit_filter system table 0.91

Copy link

@coffeegoddd DOLT

name add_cnt delete_cnt update_cnt latency
adds_only 60000 0 0 0.71
adds_updates_deletes 60000 60000 60000 3.74
deletes_only 0 60000 0 1.84
updates_only 0 0 60000 2.37

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants