Skip to content

Add support for index sort options - #705

Merged
roji merged 1 commit into
npgsql:devfrom
khellang:index-sort-options
Mar 15, 2019
Merged

roji merged 1 commit into
npgsql:devfrom
khellang:index-sort-options

Conversation

@khellang

Copy link
Copy Markdown
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

@austindrenski austindrenski left a comment

Copy link
Copy Markdown
Contributor

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.

@austindrenski

Copy link
Copy Markdown
Contributor

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

@roji roji left a comment

Copy link
Copy Markdown
Member

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.

@githubfanster

Copy link
Copy Markdown

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

khellang commented Feb 14, 2019 •

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
Contributor Author

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

@roji roji left a comment

Copy link
Copy Markdown
Member

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.

@roji roji left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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 😊

@roji roji left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

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

@khellang

khellang commented Feb 19, 2019 •

Copy link
Copy Markdown
Contributor Author

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

austindrenski commented Feb 19, 2019 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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)

@roji roji left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
Contributor Author

Hopefully most issues should be solved now 🤞

@khellang

Copy link
Copy Markdown
Contributor Author

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

@roji

roji commented Mar 1, 2019

Copy link
Copy Markdown
Member

@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?

@roji roji left a comment

Copy link
Copy Markdown
Member

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

roji commented Mar 8, 2019

Copy link
Copy Markdown
Member

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

@khellang

khellang commented Mar 8, 2019

Copy link
Copy Markdown
Contributor Author

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

@khellang
khellang force-pushed the index-sort-options branch from 0baf64e to e1cba6a Compare March 15, 2019 07:43
@khellang

Copy link
Copy Markdown
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

roji commented Mar 15, 2019

Copy link
Copy Markdown
Member

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants