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

ASF GitHub Bot commented on PHOENIX-4594:
-----------------------------------------

Github user BinShi-SecularBird commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/347#discussion_r223111306
  
    --- Diff: 
phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java
 ---
    @@ -823,12 +823,189 @@ private void testSelectQueriesWithFilters(boolean 
useStatsForParallelization) th
                     assertEquals(100 + i, rs.getInt(1));
                     i++;
                 }
    +            assertEquals(numRows, i);
    +            info = getByteRowEstimates(conn, sql, binds);
    +            // Depending on the guidepost boundary, this estimate
    +            // can be slightly off. It's called estimate for a reason.
    +            assertEquals((Long) 3L, info.getEstimatedRows());
    +            assertEquals((Long) 160L, info.getEstimatedBytes());
    +            assertTrue(info.getEstimateInfoTs() > 0);
    +            // Query whose start key is between and end key is after data.
    +            sql = "SELECT a FROM " + tableName + " WHERE K <= 120 AND K >= 
100";
    +            rs = conn.createStatement().executeQuery(sql);
    +            i = 0;
    +            numRows = 10;
    +            while (rs.next()) {
    +                assertEquals(100 + i, rs.getInt(1));
    +                i++;
    +            }
    +            assertEquals(numRows, i);
    +            info = getByteRowEstimates(conn, sql, binds);
    +            // Depending on the guidepost boundary, this estimate
    +            // can be slightly off. It's called estimate for a reason.
    +            assertEquals((Long) 10L, info.getEstimatedRows());
    +            assertEquals((Long) 720L, info.getEstimatedBytes());
    +            assertTrue(info.getEstimateInfoTs() > 0);
    +            // Query whose start key and end key are both between data.
    +            sql = "SELECT a FROM " + tableName + " WHERE K <= 109 AND K >= 
100";
    +            rs = conn.createStatement().executeQuery(sql);
    +            i = 0;
    +            numRows = 10;
    +            while (rs.next()) {
    +                assertEquals(100 + i, rs.getInt(1));
    +                i++;
    +            }
    +            assertEquals(numRows, i);
    +            info = getByteRowEstimates(conn, sql, binds);
    +            // Depending on the guidepost boundary, this estimate
    +            // can be slightly off. It's called estimate for a reason.
    +            assertEquals((Long) 10L, info.getEstimatedRows());
    +            assertEquals((Long) 720L, info.getEstimatedBytes());
    +            assertTrue(info.getEstimateInfoTs() > 0);
    +        }
    +    }
    +
    +    @Test
    +    public void testSelectQueriesWithGuidePostMovingWindows() throws 
Exception {
    +        testSelectQueriesWithGuidePostMovingWindows(0);
    +        testSelectQueriesWithGuidePostMovingWindows(1);
    +        testSelectQueriesWithGuidePostMovingWindows(2);
    +        testSelectQueriesWithGuidePostMovingWindows(10);
    +        testSelectQueriesWithGuidePostMovingWindows(256);
    +    }
    +
    +    private void testSelectQueriesWithGuidePostMovingWindows(int 
movingWindowSize) throws Exception {
    +        String tableName = generateUniqueName();
    +        try (Connection conn = DriverManager.getConnection(getUrl())) {
    +            int guidePostWidth = 20;
    +            String ddl =
    +                    "CREATE TABLE " + tableName + " (k INTEGER PRIMARY 
KEY, a bigint, b bigint)"
    +                            + " GUIDE_POSTS_WIDTH=" + guidePostWidth
    +                            + ", USE_STATS_FOR_PARALLELIZATION=true" + " 
SPLIT ON (102, 105, 108)";
    +            conn.createStatement().execute(ddl);
    --- End diff --
    
    I'll hold this change as discussed in PHOENIX-4594.


> Perform binary search on guideposts during query compilation
> ------------------------------------------------------------
>
>                 Key: PHOENIX-4594
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-4594
>             Project: Phoenix
>          Issue Type: Improvement
>            Reporter: James Taylor
>            Assignee: Bin Shi
>            Priority: Major
>         Attachments: PHOENIX-4594-0913.patch, PHOENIX-4594_0917.patch, 
> PHOENIX-4594_0918.patch
>
>
> If there are many guideposts, performance will suffer during query 
> compilation because we do a linear search of the guideposts to find the 
> intersection with the scan ranges. Instead, in 
> BaseResultIterators.getParallelScans() we should populate an array of 
> guideposts and perform a binary search. 



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

Reply via email to