[ 
https://issues.apache.org/jira/browse/NIFI-5143?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16482816#comment-16482816
 ] 

ASF GitHub Bot commented on NIFI-5143:
--------------------------------------

GitHub user mattyb149 opened a pull request:

    https://github.com/apache/nifi/pull/2728

    NIFI-5143: Initial work to support column values for paging results

    Thank you for submitting a contribution to Apache NiFi.
    
    In order to streamline the review of the contribution we ask you
    to ensure the following steps have been taken:
    
    ### For all changes:
    - [x] Is there a JIRA ticket associated with this PR? Is it referenced 
         in the commit message?
    
    - [x] Does your PR title start with NIFI-XXXX where XXXX is the JIRA number 
you are trying to resolve? Pay particular attention to the hyphen "-" character.
    
    - [x] Has your PR been rebased against the latest commit within the target 
branch (typically master)?
    
    - [x] Is your initial contribution a single, squashed commit?
    
    ### For code changes:
    - [x] Have you ensured that the full suite of tests is executed via mvn 
-Pcontrib-check clean install at the root nifi folder?
    - [x] Have you written or updated unit tests to verify your changes?
    - [ ] If adding new dependencies to the code, are these dependencies 
licensed in a way that is compatible for inclusion under [ASF 
2.0](http://www.apache.org/legal/resolved.html#category-a)? 
    - [ ] If applicable, have you updated the LICENSE file, including the main 
LICENSE file under nifi-assembly?
    - [ ] If applicable, have you updated the NOTICE file, including the main 
NOTICE file found under nifi-assembly?
    - [x] If adding new Properties, have you added .displayName in addition to 
.name (programmatic access) for each of the new properties?
    
    ### For documentation related changes:
    - [ ] Have you ensured that format looks appropriate for the output in 
which it is rendered?
    
    ### Note:
    Please ensure that once the PR is submitted, you check travis-ci for build 
issues and submit an update to your PR as soon as possible.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/mattyb149/nifi NIFI-5143

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/nifi/pull/2728.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #2728
    
----
commit bc614ce908addb3c961ae4aeb18879b4801c570a
Author: Matthew Burgess <mattyb149@...>
Date:   2018-05-21T17:45:16Z

    NIFI-5143: Initial work to support column values for paging results

----


> Allow GenerateTableFetch to use column values for partitioning
> --------------------------------------------------------------
>
>                 Key: NIFI-5143
>                 URL: https://issues.apache.org/jira/browse/NIFI-5143
>             Project: Apache NiFi
>          Issue Type: Improvement
>            Reporter: Matt Burgess
>            Assignee: Matt Burgess
>            Priority: Major
>
> GenerateTableFetch generates SQL statements for fetching "pages" of rows from 
> a database, and the SQL it generates often leverages the concept of "row 
> numbers" when doing things such as LIMIT and OFFSET.
> Oracle 11 is an example of a special case for GenerateTableFetch, because it 
> doesn't make a "row number" available for doing paging ("get rows 10 through 
> 19", e.g.). For that reason the row number is created as an extra column 
> using a nested select with an ORDER BY clause. For large tables this can be 
> very inefficient.
> In a general sense, the user may have a column that contains integer IDs and 
> would like to have a more efficient query. I propose the following as a 
> generic solution that would mostly benefit this kind of use case:
>  - Add a property to GenerateTableFetch to "Use Column Values For 
> Partitioning". This would be a boolean property defaulting to false to retain 
> current behavior.
>  - If the maximum value column type is numeric and "Use Column Values For 
> Partitioning" is true, fetch the minimum value of the column (after the where 
> clause is applied)
>  - If "Use Column Values For Partitioning" is true, then determine the page 
> offsets by taking the difference of the maximum value and minimum value, 
> dividing by the Partition Size.
> These changes would use the "Max-value Columns" values rather than the result 
> set row numbers for figuring out the paging. The documentation needs to be 
> very clear on when this property should be used. For example, when "Use 
> Column Values For Partitioning" is true, then the column values should be 
> evenly distributed and not sparse, for best performance.
> As a counterexample, consider the following:
>  - Use Column Values For Partitioning = true
>  - Max Value Column = "id"
>  - Table "myTable" has only 3 rows, one with id = 1, one with id = 50, one 
> with id = 100
>  - Partition Size = 5
> GenerateTableFetch would generate 20 flow files, of the following pattern:
>  SELECT * from myTable where ID >= 1 AND ID < 5
>  SELECT * from myTable where ID >= 5 AND ID < 10
>  SELECT * from myTable where ID >= 10 AND ID < 15
>  ...
>  SELECT * from myTable where ID >= 50 AND ID < 55
>  ...
>  SELECT * from myTable where ID >= 100 AND ID < 105
> Note that only 3 flow files out of 20 will contain SQL statements that would 
> retrieve any rows. The rest will return empty ResultSets. However when the 
> columns are appropriate for use of their values, this improvement could be 
> quite substantial.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to