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

Sync index info #36462

Merged
merged 13 commits into from Dec 11, 2023
Merged

Sync index info #36462

merged 13 commits into from Dec 11, 2023

Conversation

qnkhuat
Copy link
Contributor

@qnkhuat qnkhuat commented Dec 6, 2023

Milestone 1 of #36452.

This adds a new column metabase_field.database_indexed, it's set to true during sync if there is a single index on the column, or it's the 1st column of a composite index.

For DBs that do not support indexing, metabase_field.database_indexed should be nil.

@metabase-bot metabase-bot bot added the .Team/BackendComponents also known as BEC label Dec 6, 2023
Copy link

deploysentinel bot commented Dec 6, 2023

No failed tests 🎉

@qnkhuat qnkhuat added the no-backport Do not backport this PR to any branch label Dec 8, 2023
@qnkhuat qnkhuat requested a review from a team December 8, 2023 10:54
src/metabase/driver/postgres.clj Outdated Show resolved Hide resolved
src/metabase/driver/sql_jdbc/sync/describe_table.clj Outdated Show resolved Hide resolved
src/metabase/driver/sql_jdbc/sync/describe_table.clj Outdated Show resolved Hide resolved
:native-requires-specified-collection})
:native-requires-specified-collection

;; Does the driver support column(s) indexing
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this should read:
Does the driver support column(s) support storing index info

Implementing the multimethods to sync index info should be separate from whether indices are supported on the database or not.

Also wondering whether the feature should be called :index-info

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yea index-info sounds better to me, renamed in 07847b5

@qnkhuat qnkhuat requested review from calherries and a team December 11, 2023 04:22
Copy link
Contributor

@calherries calherries left a comment

Choose a reason for hiding this comment

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

LGTM, just a couple of things to tidy up

:removed-indexes 0})

(defn maybe-sync-indexes-for-table!
"Sync the indexes for `table` if the driver supports indexing."
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's worth being precise here about what we mean by "supports indexing"

Suggested change
"Sync the indexes for `table` if the driver supports indexing."
"Sync the indexes for `table` if the driver supports storing index info."

Comment on lines 58 to 59
(when indexed?
(add! (sql.tx/create-index-sql driver (:table-name tabledef) [(:field-name fielddef)]))))
Copy link
Contributor

Choose a reason for hiding this comment

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

Adding this to the FK doseq block is inconsistent with the way column comments are added on lines 64-68 below, which has its own separate doseq. I don't care either way, but as long as its consistent it'll be easier to read and understand

Copy link
Contributor

@calherries calherries left a comment

Choose a reason for hiding this comment

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

LGTM, just a couple of things to tidy up

@qnkhuat qnkhuat enabled auto-merge (squash) December 11, 2023 14:51
@qnkhuat qnkhuat merged commit a9d2006 into master Dec 11, 2023
104 of 105 checks passed
@qnkhuat qnkhuat deleted the ngoc-sync-index-info branch December 11, 2023 15:21
Copy link

@qnkhuat Did you forget to add a milestone to the issue for this PR? When and where should I add a milestone?

@qnkhuat qnkhuat added this to the 0.49 milestone Dec 11, 2023
qnkhuat added a commit that referenced this pull request Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-backport Do not backport this PR to any branch .Team/BackendComponents also known as BEC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants