You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@phoenix.apache.org by "James Taylor (JIRA)" <ji...@apache.org> on 2015/04/10 02:15:12 UTC

[jira] [Commented] (PHOENIX-1834) Collect row counts per tenant view

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

James Taylor commented on PHOENIX-1834:
---------------------------------------

FWIW, you can get a good approximation of this by looking at the guideposts that span that tenant's data. We should develop APIs around accessing stats, but I think the raw information is there. For example, this will access the client-side cached information:
{code}
    QueryPlan viewPlan = stmt.unwrap(PhoenixStatement.class).compileQuery("SELECT * FROM YOUR_VIEW");
    int nViewGuidePosts = viewPlan.getKeyRanges().size();
    QueryPlan basePlan = stmt.unwrap(PhoenixStatement.class).compileQuery("SELECT * FROM YOUR_BASE_TABLE");
    int nBaseGuidePosts = basePlan.getKeyRanges().size();
    PTable table = conn.unwrap(PhoenixConnection.class).getMetaDataCache().getTable(new PTableKey(null, "YOUR_BASE_TABLE"));
    long baseRowCount = table.getStats().getGuidePosts().get(table.getEmptyColumnFamily()).getRowCount();
    double percOfTable = (double) nViewGuidePosts / nBaseGuidePosts;
    long viewRowCount = (long)(baseRowCount * percOfTable);
{code}

Would be an interesting Phoenix week project to develop a set of APIs in PhoenixRuntime around this based on the stats you'd like to gather. Note that stats have to be enabled for all this to work, of course.

> Collect row counts per tenant view
> ----------------------------------
>
>                 Key: PHOENIX-1834
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-1834
>             Project: Phoenix
>          Issue Type: Sub-task
>            Reporter: Eli Levine
>
> In multi-tenant environments it would be useful to query stats for row count per tenant view. [~ram_krish], any thoughts on the feasibility of this?
> It would probably be useful to extend this to all views but starting with tenant views is a good start IMHO, since their view definitions are simpler and tenant_id is guaranteed to be the first rowkey component (after salt byte).



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