[jira] [Commented] (PHOENIX-1594) Using KeyOnlyFilter for simple query "select count(1) from "

Fri, 16 Jan 2015 11:00:31 -0800

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

James Taylor commented on PHOENIX-1594:
---------------------------------------

That'd be a pretty serious perf regression (FYI, [~mujtabachohan]). The code 
that is supposed to use a KeyOnlyFilter is in BaseResultIterators, line 160 (in 
the constructor):
{code}
    public BaseResultIterators(QueryPlan plan, Integer perScanLimit) throws 
SQLException {
        super(plan.getContext(), plan.getTableRef(), plan.getGroupBy(), 
plan.getOrderBy(), plan.getStatement().getHint());
        this.plan = plan;
        StatementContext context = plan.getContext();
        TableRef tableRef = plan.getTableRef();
        PTable table = tableRef.getTable();
        FilterableStatement statement = plan.getStatement();
        RowProjector projector = plan.getProjector();
        physicalTableName = table.getPhysicalName().getBytes();
        tableStats = useStats() ? new 
MetaDataClient(context.getConnection()).getTableStats(table) : 
PTableStats.EMPTY_STATS;
        Scan scan = context.getScan();
        // Used to tie all the scans together during logging
        scanId = UUID.randomUUID().toString();
        if (projector.isProjectEmptyKeyValue()) {
            Map<byte [], NavigableSet<byte []>> familyMap = scan.getFamilyMap();
            // If nothing projected into scan and we only have one column 
family, just allow everything
            // to be projected and use a FirstKeyOnlyFilter to skip from row to 
row. This turns out to
            // be quite a bit faster.
            // Where condition columns also will get added into familyMap
            // When where conditions are present, we can not add 
FirstKeyOnlyFilter at beginning.
            if (familyMap.isEmpty() && 
context.getWhereCoditionColumns().isEmpty()
                    && table.getColumnFamilies().size() == 1) {
                // Project the one column family. We must project a column 
family since it's possible
                // that there are other non declared column families that we 
need to ignore.
                
scan.addFamily(table.getColumnFamilies().get(0).getName().getBytes());
                ScanUtil.andFilterAtBeginning(scan, new FirstKeyOnlyFilter());
            } else {
{code}

> Using KeyOnlyFilter for simple query "select count(1) from <table>"
> -------------------------------------------------------------------
>
>                 Key: PHOENIX-1594
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-1594
>             Project: Phoenix
>          Issue Type: Improvement
>            Reporter: Jeffrey Zhong
>
> I found that underlying scan for query "select count(1) or count(*) from 
> <table>" still project all columns. 
> It should be fast if we use KeyOnlyFilter for this simple query.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to