-
Notifications
You must be signed in to change notification settings - Fork 127
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
Feature: Introduce the 'SkipQuery' operation. #377
Comments
This could be potentially used to support Cursor based paging as laid out by Relay spec (extension of GraphQL) for cursor based movemeent forward and backward through a result set. This would be more flexible than the current page BatchQuery (though even that could work with the right math). Relay Cursor Paging Spec - Arguments As an API this the Relay spec refers to this as Slicing, and cursor paging spec calls for forward, backward, and combined cursor movement using: first, after, last, before But, as the RepoDb BatchQuery exists now, it won't work because the key element for this to work in a general way is that the Cursor needs to returned in the results! Without the Cursor value as derived from the index of each record in a sorted resultset; meaning the actual RowNumber needs to be part of the results. And ideal solution would be a QuerySlice() method that:
I have already been working on a POC for this as an Extension method and my initial version is currently it working great for Sql Server using a customize version of the exsting Batch Query sql that adds Anything more ideal requires access to some Since @mikependon just pointed me to this Feature, I just wanted to put this idea forth as an expansion of this Feature to see what thoughts there may be? |
Linking this User Story (#634) |
Also as a note on this particular feature request for "SkipQuery"... it's really just a variation of BatchQuery without the page calculation -- both can be mapped to starting row index, and ending row index in a sorted set of results.. So, if re-factored correctly the very same underlying queries can work for both.. |
@cajuncoding - I remembered talking to a colleague about considering the SkipQuery implementation into the BatchQuery operation, I guess it was last year or early this year. But I personally ended not to proceed with the change due to its internal usage in the organization (that time RepoDB is not yet fully publicly exposed). Maybe this is a good question to ask to the community, should we still implement the SkipQuery separately? Or, should we just simply move the SkipQuery behavior into the existing BatchQuery? |
@mikependon While I personally have always been fan of the Page/Page-size parameter set (eg. batches), it does seem that the industry prefers the Skip/Take... probably because it's a slicing approach whereby there really isn't a specific Page. Though Page/Page-size (or rows-per-batch as in RepoDb) can be mapped to a slice, mapping the other way from Skip/Take back to a Page/PageSize only works if we assume that the Take parameter is constant as the client pages through results. But I guess this is not a requirement for Skip/Take. So as I"m working on adding OffsetPaging support in HotChocolate.RepoDb.SqlServer, having a directry Skip/Take api in RepoDb would make it alot easier, as of now I'm convering the Skip to a Page using math (as stated above, assuming the Take is likely to remain constant). I can see that RepoDb is getting harder and harder to maintain as the code base grows due to support for a variety of DB implementations, both Synchronous & Asynchronous operations, and a great API. My 2-cents would be to add it, but do so in a way where it's just a layer on top of the same underlying queries (keep these queries DRY) for both Batch and Skip/Take. For example, with Sql Servder my research shows there to be no notable performance benefit to the Offset query syntax vs RowOver()... and RowOver() might even be faster. But, having a Skip/Take api exposed will make code of users of RepoDb cleaner and more descriptive -- and likely help alot of novice developers. |
Cool, thanks for sharing your opinion. Any breaking change (even it is minor), like this would be a part of the next version >= 1.13.x. |
I was thinking it wouldn't be a breaking change at all, just a couple of net new apis taking in the skip/take parameters and leveraging the same internal plumbing (slight refactoring), but def. keep the current batch apis fully compatible with current behavior: Net new api (and overloads):
Same for cursor slice paging with a net new api and overloads:
|
Hello, I am interested in grabing this feature as it looks pretty simple. While waiting for a response, I will dig in the project and tests. |
Cool! Looking forward for your contribution to RepoDB. It is highly appreciated! We suggest to follow the batch query implementation and structures. :) |
I am running into an issue in the integration tests. In Helper.AssertPropertiesEquality, ColumnTimestampWithTimeZone doesn't have the same value for expected and actual. Thing is I am in UTC+1, so the values from the database are 1 hour apart. |
I could not check for now due to being off from my laptop, but timezone should not be a problem here, it should be handled accordingly. You can just proceed with the PR and we will debug this Integration Tests issue in the coming days. |
Done in #1123 |
Great and thanks for the PR. We will review ASAP |
The fixes to this will be available on the release version >= v1.13.1. |
Description
This operation will work like 'BatchQuery' however, instead of paging, it will use the skipping.
For BatchQuery, the codes below will return the 20th to 30th rows.
For SkipQuery, the codes below will return the 3rd to 12th rows.
Acceptance Criteria
Impact
Less impact. Should not affect existing functionality.
The text was updated successfully, but these errors were encountered: