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

Add support for index sort options #705

Merged
merged 1 commit into from
Mar 15, 2019
Merged

Conversation

khellang
Copy link
Contributor

Closes #326

@khellang khellang force-pushed the index-sort-options branch 2 times, most recently from 774f9d2 to 48676c0 Compare November 15, 2018 20:07
Copy link
Contributor

@austindrenski austindrenski 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, just a few questions.

src/EFCore.PG/Extensions/NpgsqlIndexBuilderExtensions.cs Outdated Show resolved Hide resolved
src/EFCore.PG/Migrations/NpgsqlMigrationsSqlGenerator.cs Outdated Show resolved Hide resolved
src/EFCore.PG/Extensions/NpgsqlIndexBuilderExtensions.cs Outdated Show resolved Hide resolved
@austindrenski austindrenski added the enhancement New feature or request label Nov 15, 2018
@austindrenski
Copy link
Contributor

@khellang Would you mind rebasing when you have a chance?

Copy link
Member

@roji roji left a comment

Choose a reason for hiding this comment

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

Aside from the API shape (one method vs. several), I have a more general comment.

While it's totally fine to have this control over the index, it's important to think about the interaction with ORDER BY, which also has NULLS FIRST/LAST (see #627). The ORDER BY null ordering is managed globally as a context option, and cannot be controlled query-by-query. At the moment that feature is internal-only, for testing purposes (compatibility with MSSQL), since if users start using NULLS FIRST while their indices are NULLS LAST there may be a significant perf degradation (haven't actually checked this). If there really is a need to expose ORDER BY null ordering to users, we may want to have a single context option which also affects the index setting (so that all indices would be created NULLS FIRST as well).

Just something to think about, this doesn't necessarily impact this PR.

src/EFCore.PG/Extensions/NpgsqlIndexBuilderExtensions.cs Outdated Show resolved Hide resolved
@githubfanster
Copy link

Hi! I was just wondering if this change has been merged and available for us to use? if so, what version? thanks for new info!

@khellang
Copy link
Contributor Author

khellang commented Feb 14, 2019

Hi! I was just wondering if this change has been merged and available for us to use? if so, what version? thanks for new info!

@githubfanster Nope, it's still sitting here, unmerged. I'll see if I can pick this up again.

@khellang
Copy link
Contributor Author

Alright, updated. Hopefully there should be few issues left now 🤞

Copy link
Member

@roji roji left a comment

Choose a reason for hiding this comment

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

Looks great! See my small comments, other than that from my side we're good to go.

One last thing is that there's an issue tracking ASC/DESC support for indices at the EF Core level - dotnet/efcore#4150. Ideally this would be implemented there and we'd reuse the same SortOrder enum, or whatever mechanism is accepted there. If not, I think it's OK for us to release our own thing too - we shouldn't get blocked.

However, @khellang or someone else, if you feel like submitting this functionality upstream that would be ideal - we could adapt our own implementation to that. I wouldn't block this PR for that, though.

src/EFCore.PG/Extensions/NpgsqlIndexBuilderExtensions.cs Outdated Show resolved Hide resolved
src/EFCore.PG/Extensions/NpgsqlIndexBuilderExtensions.cs Outdated Show resolved Hide resolved
src/EFCore.PG/Metadata/INpgsqlIndexAnnotations.cs Outdated Show resolved Hide resolved
src/EFCore.PG/Metadata/NpgsqlIndexAnnotations.cs Outdated Show resolved Hide resolved
src/EFCore.PG/Migrations/NpgsqlMigrationsSqlGenerator.cs Outdated Show resolved Hide resolved
src/EFCore.PG/Migrations/NpgsqlMigrationsSqlGenerator.cs Outdated Show resolved Hide resolved
Copy link
Member

@roji roji left a comment

Choose a reason for hiding this comment

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

Thanks @khellang, this looks great!

@khellang
Copy link
Contributor Author

I've started on the scaffolding bits for this, but need a bit more time to get the tests written properly. I don't think this PR needs to wait for it though. Just letting you know 😊

Copy link
Member

@roji roji left a comment

Choose a reason for hiding this comment

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

Looks very good @khellang, thanks.

First, see the comment about the possible method-specificity of the sorting bits in scaffolding.

Also, it seems like collation isn't being scaffolded - this seems like it might be a simple matter of joining on indcollation etc. For completeness it would be nice to have this in this PR as well - did you run into any issue with this?

@khellang
Copy link
Contributor Author

Also, it seems like collation isn't being scaffolded - this seems like it might be a simple matter of joining on indcollation etc. For completeness it would be nice to have this in this PR as well - did you run into any issue with this?

Ah, no, for some reason I just forgot 😂

@khellang
Copy link
Contributor Author

Hmm. Looks like a legit CI failure. Passed on my Mac. I wonder if there's a difference between included collation on different OS'es? 🤔

@austindrenski
Copy link
Contributor

Possibly... Or something else related to the updated base image (#822, appveyor/ci#2872).

@khellang
Copy link
Contributor Author

khellang commented Feb 19, 2019

Looks like it (under 23.2.2.1. Standard Collations):

On all platforms, the collations named default, C, and POSIX are available. Additional collations may be available depending on operating system support.

I guess I'll have to use POSIX for the unit test then 😅

@austindrenski
Copy link
Contributor

austindrenski commented Feb 19, 2019

Looks like it:

On all platforms, the collations named default, C, and POSIX are available. Additional collations may be available depending on operating system support.

I guess I'll have to use POSIX for the unit test then 😅

Nice find. Can you edit to include a citation?

@khellang
Copy link
Contributor Author

Nice find. Can you edit to include a citation?

Updated. (https://www.postgresql.org/docs/current/collation.html, under 23.2.2.1. Standard Collations)

Copy link
Member

@roji roji left a comment

Choose a reason for hiding this comment

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

Thanks, it's great to see the collation scaffolding support.

Two things remain from my side - yet another annoying comment from me about the default sort order and implications, and a confirmation on the indoption bit parsing across index methods.

@khellang khellang force-pushed the index-sort-options branch 2 times, most recently from 7fbe6bc to 2a364c9 Compare February 28, 2019 21:39
@khellang
Copy link
Contributor Author

Hopefully most issues should be solved now 🤞

@khellang
Copy link
Contributor Author

Hmm. That CI failure (Test_change_tracking_key_sizes) seems to be unrelated?

@roji
Copy link
Member

roji commented Mar 1, 2019

@khellang that has nothing to do with you, just pushed a commit to skip that test for now, can you please rebase on top of that?

Copy link
Member

@roji roji left a comment

Choose a reason for hiding this comment

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

I think we can merge this - see two unimportant comments, you can decide if you want to deal with them or not. Otherwise either squash your commits and force-push or let me know and I'll take care of everything.

Thanks for this valuable contribution and for the considerable patience while working on this :)

@roji
Copy link
Member

roji commented Mar 8, 2019

@khellang I think we're still waiting on some very minor things here, can you confirm? It would be good to finally merge :)

@khellang
Copy link
Contributor Author

khellang commented Mar 8, 2019

Yup, I just haven't had time to fix them yet. I'll get to it this week 👍

@khellang
Copy link
Contributor Author

@roji Sorry about the delay. I've added the tweaks from the last review and squashed the commits 👍

@roji roji merged commit 7062845 into npgsql:dev Mar 15, 2019
@roji
Copy link
Member

roji commented Mar 15, 2019

Merged, thanks for the patient work @khellang!

@khellang khellang deleted the index-sort-options branch March 15, 2019 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants