Author: elserj
Date: Thu Jan 9 16:46:20 2020
New Revision: 1872559
URL: http://svn.apache.org/viewvc?rev=1872559&view=rev
Log:
Getting faq re-published
Removed:
phoenix/site/publish/0.
Modified:
phoenix/site/publish/faq.html
phoenix/site/publish/language/datatypes.html
phoenix/site/publish/language/functions.html
phoenix/site/publish/language/index.html
phoenix/site/source/src/site/markdown/faq.md
Modified: phoenix/site/publish/faq.html
URL:
http://svn.apache.org/viewvc/phoenix/site/publish/faq.html?rev=1872559&r1=1872558&r2=1872559&view=diff
==============================================================================
--- phoenix/site/publish/faq.html (original)
+++ phoenix/site/publish/faq.html Thu Jan 9 16:46:20 2020
@@ -0,0 +1,694 @@
+
+<!DOCTYPE html>
+<!--
+ Generated by Apache Maven Doxia at 2020-01-09
+ Rendered using Reflow Maven Skin 1.1.0
(http://andriusvelykis.github.io/reflow-maven-skin)
+-->
+<html xml:lang="en" lang="en">
+
+ <head>
+ <meta charset="UTF-8" />
+ <title>F.A.Q. | Apache Phoenix</title>
+ <meta name="viewport" content="width=device-width,
initial-scale=1.0" />
+ <meta name="description" content="" />
+ <meta http-equiv="content-language" content="en" />
+
+ <link
href="//netdna.bootstrapcdn.com/bootswatch/2.3.2/flatly/bootstrap.min.css"
rel="stylesheet" />
+ <link
href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-responsive.min.css"
rel="stylesheet" />
+ <link href="./css/bootswatch.css" rel="stylesheet" />
+ <link href="./css/reflow-skin.css" rel="stylesheet" />
+
+ <link href="//yandex.st/highlightjs/7.5/styles/default.min.css"
rel="stylesheet" />
+
+ <link href="./css/lightbox.css" rel="stylesheet" />
+
+ <link href="./css/site.css" rel="stylesheet" />
+ <link href="./css/print.css" rel="stylesheet" media="print" />
+
+ <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
+ <!--[if lt IE 9]>
+ <script
src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
+ <![endif]-->
+
+
+
+ </head>
+
+ <body class="page-faq project-phoenix-site" data-spy="scroll"
data-offset="60" data-target="#toc-scroll-target">
+
+ <div class="navbar navbar-fixed-top">
+ <div class="navbar-inner">
+ <div class="container">
+ <a class="btn btn-navbar"
data-toggle="collapse" data-target="#top-nav-collapse">
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </a>
+ <a class="brand" href="index.html"><div
class="xtoplogo"></div></a>
+ <div class="nav-collapse collapse"
id="top-nav-collapse">
+ <ul class="nav pull-right">
+ <li class="dropdown">
+ <a href="#"
class="dropdown-toggle" data-toggle="dropdown">About <b class="caret"></b></a>
+ <ul
class="dropdown-menu">
+ <li ><a
href="index.html" title="Overview">Overview</a></li>
+ <li ><a
href="who_is_using.html" title="Who is Using">Who is Using</a></li>
+ <li ><a
href="recent.html" title="Recent Improvements">Recent Improvements</a></li>
+ <li ><a
href="roadmap.html" title="Roadmap">Roadmap</a></li>
+ <li ><a
href="news.html" title="News">News</a></li>
+ <li ><a
href="performance.html" title="Performance">Performance</a></li>
+ <li ><a
href="team.html" title="Team">Team</a></li>
+ <li ><a
href="resources.html" title="Presentations">Presentations</a></li>
+ <li ><a
href="mailing_list.html" title="Mailing Lists">Mailing Lists</a></li>
+ <li ><a
href="source.html" title="Source Repository">Source Repository</a></li>
+ <li ><a
href="issues.html" title="Issue Tracking">Issue Tracking</a></li>
+ <li ><a
href="download.html" title="Download">Download</a></li>
+ <li ><a
href="installation.html" title="Installation">Installation</a></li>
+ <li
class="divider"/>
+ <li ><a
href="contributing.html" title="How to Contribute">How to Contribute</a></li>
+ <li ><a
href="develop.html" title="How to Develop">How to Develop</a></li>
+ <li ><a
href="building_website.html" title="How to Update Website">How to Update
Website</a></li>
+ <li ><a
href="release.html" title="How to Release">How to Release</a></li>
+ <li
class="divider"/>
+ <li ><a
href="http://www.apache.org/licenses/" title="License"
class="externalLink">License</a></li>
+ </ul>
+ </li>
+ <li class="dropdown">
+ <a href="#"
class="dropdown-toggle" data-toggle="dropdown">Using <b class="caret"></b></a>
+ <ul
class="dropdown-menu">
+ <li
class="active"><a href="" title="F.A.Q.">F.A.Q.</a></li>
+ <li ><a
href="Phoenix-in-15-minutes-or-less.html" title="Quick Start">Quick
Start</a></li>
+ <li ><a
href="building.html" title="Building">Building</a></li>
+ <li ><a
href="tuning_guide.html" title="Tuning">Tuning</a></li>
+ <li ><a
href="explainplan.html" title="Explain Plan">Explain Plan</a></li>
+ <li ><a
href="tuning.html" title="Configuration">Configuration</a></li>
+ <li ><a
href="upgrading.html" title="Backward Compatibility">Backward
Compatibility</a></li>
+ <li ><a
href="release_notes.html" title="Release Notes">Release Notes</a></li>
+ <li ><a
href="pherf.html" title="Performance Testing">Performance Testing</a></li>
+ <li
class="divider"/>
+ <li ><a
href="phoenix_spark.html" title="Apache Spark Integration">Apache Spark
Integration</a></li>
+ <li ><a
href="hive_storage_handler.html" title="Phoenix Storage Handler for Apache
Hive">Phoenix Storage Handler for Apache Hive</a></li>
+ <li ><a
href="pig_integration.html" title="Apache Pig Integration">Apache Pig
Integration</a></li>
+ <li ><a
href="phoenix_mr.html" title="Map Reduce Integration">Map Reduce
Integration</a></li>
+ <li ><a
href="flume.html" title="Apache Flume Plugin">Apache Flume Plugin</a></li>
+ <li ><a
href="kafka.html" title="Apache Kafka Plugin">Apache Kafka Plugin</a></li>
+ <li ><a
href="python.html" title="Python Driver">Python Driver</a></li>
+ </ul>
+ </li>
+ <li class="dropdown">
+ <a href="#"
class="dropdown-toggle" data-toggle="dropdown">Addons <b class="caret"></b></a>
+ <ul
class="dropdown-menu">
+ <li ><a
href="http://docs.aws.amazon.com/ElasticMapReduce/latest/ReleaseGuide/emr-phoenix.html"
title="Phoenix on Amazon EMR" class="externalLink">Phoenix on Amazon
EMR</a></li>
+ <li ><a
href="http://python-phoenixdb.readthedocs.io/en/latest" title="Phoenix Adapter
for Python" class="externalLink">Phoenix Adapter for Python</a></li>
+ <li ><a
href="phoenix_orm.html" title="Phoenix ORM Library">Phoenix ORM Library</a></li>
+ <li ><a
href="https://prestosql.io/docs/current/connector/phoenix.html" title="Phoenix
Connector for Presto" class="externalLink">Phoenix Connector for Presto</a></li>
+ <li ><a
href="omid.html" title="Apache Phoenix Omid Transaction Manager">Apache Phoenix
Omid Transaction Manager</a></li>
+ <li ><a
href="tephra.html" title="Apache Phoenix Tephra Transaction Manager">Apache
Phoenix Tephra Transaction Manager</a></li>
+ </ul>
+ </li>
+ <li class="dropdown">
+ <a href="#"
class="dropdown-toggle" data-toggle="dropdown">Features <b
class="caret"></b></a>
+ <ul
class="dropdown-menu">
+ <li ><a
href="transactions.html" title="Transactions">Transactions</a></li>
+ <li ><a
href="udf.html" title="User-defined Functions">User-defined Functions</a></li>
+ <li
class="divider"/>
+ <li ><a
href="secondary_indexing.html" title="Secondary Indexes">Secondary
Indexes</a></li>
+ <li ><a
href="columnencoding.html" title="Storage Formats">Storage Formats</a></li>
+ <li ><a
href="atomic_upsert.html" title="Atomic Upsert">Atomic Upsert</a></li>
+ <li ><a
href="namspace_mapping.html" title="Namespace Mapping">Namespace
Mapping</a></li>
+ <li ><a
href="update_statistics.html" title="Statistics Collection">Statistics
Collection</a></li>
+ <li ><a
href="rowtimestamp.html" title="Row Timestamp Column">Row Timestamp
Column</a></li>
+ <li ><a
href="paged.html" title="Paged Queries">Paged Queries</a></li>
+ <li ><a
href="salted.html" title="Salted Tables">Salted Tables</a></li>
+ <li ><a
href="skip_scan.html" title="Skip Scan">Skip Scan</a></li>
+ <li ><a
href="tablesample.html" title="Table Sampling">Table Sampling</a></li>
+ <li
class="divider"/>
+ <li ><a
href="views.html" title="Views">Views</a></li>
+ <li ><a
href="multi-tenancy.html" title="Multi tenancy">Multi tenancy</a></li>
+ <li ><a
href="dynamic_columns.html" title="Dynamic Columns">Dynamic Columns</a></li>
+ <li
class="divider"/>
+ <li ><a
href="bulk_dataload.html" title="Bulk Loading">Bulk Loading</a></li>
+ <li ><a
href="server.html" title="Query Server">Query Server</a></li>
+ <li ><a
href="metrics.html" title="Metrics">Metrics</a></li>
+ <li ><a
href="tracing.html" title="Tracing">Tracing</a></li>
+ <li ><a
href="cursors.html" title="Cursor">Cursor</a></li>
+ </ul>
+ </li>
+ <li class="dropdown">
+ <a href="#"
class="dropdown-toggle" data-toggle="dropdown">Reference <b
class="caret"></b></a>
+ <ul
class="dropdown-menu">
+ <li ><a
href="language/index.html" title="Grammar">Grammar</a></li>
+ <li ><a
href="language/functions.html" title="Functions">Functions</a></li>
+ <li ><a
href="language/datatypes.html" title="Datatypes">Datatypes</a></li>
+ <li ><a
href="array_type.html" title="ARRAY type">ARRAY type</a></li>
+ <li
class="divider"/>
+ <li ><a
href="sequences.html" title="Sequences">Sequences</a></li>
+ <li ><a
href="joins.html" title="Joins">Joins</a></li>
+ <li ><a
href="subqueries.html" title="Subqueries">Subqueries</a></li>
+ <li ><a
href="explainplan.html" title="Explain Plan">Explain Plan</a></li>
+ </ul>
+ </li>
+ </ul>
+ </div><!--/.nav-collapse -->
+ </div>
+ </div>
+ </div>
+
+ <div class="container">
+
+ <!-- Masthead
+ ================================================== -->
+
+ <header>
+ </header>
+
+ <div class="main-body">
+ <div class="row">
+ <div class="span12">
+ <div class="body-content">
+<div class="page-header">
+ <h1>F.A.Q.</h1>
+</div>
+<ul>
+ <li><a href="#I_want_to_get_started_Is_there_a_Phoenix_Hello_World">I want to
get started. Is there a Phoenix Hello World?</a></li>
+ <li><a href="#What_is_the_Phoenix_JDBC_URL_syntax">What is the Phoenix JDBC
URL syntax?</a></li>
+ <li><a href="#Is_there_a_way_to_bulk_load_in_Phoenix">Is there a way to bulk
load in Phoenix?</a></li>
+ <li><a href="#How_I_map_Phoenix_table_to_an_existing_HBase_table">How I map
Phoenix table to an existing HBase table?</a></li>
+ <li><a href="#Are_there_any_tips_for_optimizing_Phoenix">Are there any tips
for optimizing Phoenix?</a></li>
+ <li><a href="#How_do_I_create_Secondary_Index_on_a_table">How do I create
Secondary Index on a table?</a></li>
+ <li><a href="#Why_isnt_my_secondary_index_being_used">Why isnât my
secondary index being used?</a></li>
+ <li><a href="#How_fast_is_Phoenix_Why_is_it_so_fast">How fast is Phoenix? Why
is it so fast?</a></li>
+ <li><a href="#How_do_I_connect_to_secure_HBase_cluster">How do I connect to
secure HBase cluster?</a></li>
+ <li><a href="#How_do_I_connect_with_HBase_running_on_Hadoop-2">How do I
connect with HBase running on Hadoop-2?</a></li>
+ <li><a
href="#Can_phoenix_work_on_tables_with_arbitrary_timestamp_as_flexible_as_HBase_API">Can
phoenix work on tables with arbitrary timestamp as flexible as HBase
API?</a></li>
+ <li><a href="#Why_isnt_my_query_doing_a_RANGE_SCAN">Why isnât my query
doing a RANGE SCAN?</a></li>
+ <li><a href="#Should_I_pool_Phoenix_JDBC_Connections">Should I pool Phoenix
JDBC Connections?</a></li>
+ <li><a href="#Why_empty_key_value">Why does Phoenix add an empty or dummy
KeyValue when doing an upsert?</a></li>
+</ul>
+<div class="section">
+ <div class="section">
+ <h3 id="I_want_to_get_started._Is_there_a_Phoenix_Hello_World">I want to get
started. Is there a Phoenix <i>Hello World</i>?</h3>
+ <p><i>Pre-requisite:</i> Download latest Phoenix from <a
href="download.html">here</a> and copy phoenix-*.jar to HBase lib folder and
restart HBase.</p>
+ <p><b>1. Using console</b></p>
+ <ol style="list-style-type: decimal">
+ <li>Start Sqlline: <tt>$ sqlline.py [zookeeper]</tt></li>
+ <li>Execute the following statements when Sqlline connects:</li>
+ </ol>
+ <div class="source">
+ <pre>create table test (mykey integer not null primary key, mycolumn
varchar);
+upsert into test values (1,'Hello');
+upsert into test values (2,'World!');
+select * from test;
+</pre>
+ </div>
+ <ol style="list-style-type: decimal">
+ <li>You should get the following output</li>
+ </ol>
+ <div class="source">
+ <pre>+-------+------------+
+| MYKEY | MYCOLUMN |
++-------+------------+
+| 1 | Hello |
+| 2 | World! |
++-------+------------+
+</pre>
+ </div>
+ <p><b>2. Using java</b></p>
+ <p>Create test.java file with the following content:</p>
+ <div class="source">
+ <pre>import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.PreparedStatement;
+import java.sql.Statement;
+
+public class test {
+
+ public static void main(String[] args) throws SQLException {
+ Statement stmt = null;
+ ResultSet rset = null;
+
+ Connection con =
DriverManager.getConnection("jdbc:phoenix:[zookeeper]");
+ stmt = con.createStatement();
+
+ stmt.executeUpdate("create table test (mykey integer not
null primary key, mycolumn varchar)");
+ stmt.executeUpdate("upsert into test values
(1,'Hello')");
+ stmt.executeUpdate("upsert into test values
(2,'World!')");
+ con.commit();
+
+ PreparedStatement statement = con.prepareStatement("select
* from test");
+ rset = statement.executeQuery();
+ while (rset.next()) {
+
System.out.println(rset.getString("mycolumn"));
+ }
+ statement.close();
+ con.close();
+ }
+}
+</pre>
+ </div>
+ <p>Compile and execute on command line</p>
+ <p><tt>$ javac test.java</tt></p>
+ <p><tt>$ java -cp "../phoenix-[version]-client.jar:."
test</tt></p>
+ <p>You should get the following output</p>
+ <p><tt>Hello</tt> <tt>World!</tt></p>
+ </div>
+ <div class="section">
+ <h3 id="What_is_the_Phoenix_JDBC_URL_syntax">What is the Phoenix JDBC URL
syntax?</h3>
+ <div class="section">
+ <h4 id="Thick_Driver">Thick Driver</h4>
+ <p>The Phoenix (Thick) Driver JDBC URL syntax is as follows (where elements
in square brackets are optional):</p>
+ <p><tt>jdbc:phoenix:[comma-separated ZooKeeper Quorum [:port [:hbase root
znode [:kerberos_principal [:path to kerberos keytab] ] ] ]</tt></p>
+ <p>The simplest URL is:</p>
+ <p><tt>jdbc:phoenix:localhost</tt></p>
+ <p>Whereas the most complicated URL is:</p>
+
<p><tt>jdbc:phoenix:zookeeper1.domain,zookeeper2.domain,zookeeper3.domain:2181:/hbase-1:[email protected]:/etc/security/keytabs/phoenix.keytab</tt></p>
+ <p>Please note that each optional element in the URL requires all previous
optional elements. For example, to specify the HBase root ZNode, the ZooKeeper
port <i>must</i> also be specified.</p>
+ <p>This information is initially covered on the <a href="/#connStr">index
page</a>.</p>
+ </div>
+ <div class="section">
+ <h4 id="Thin_Driver">Thin Driver</h4>
+ <p>The Phoenix Thin Driver (used with the Phoenix Query Server) JDBC URL
syntax is as follows:</p>
+ <p><tt>jdbc:phoenix:thin:[key=value[;key=value...]]</tt></p>
+ <p>There are a number of keys exposed for client-use. The most
commonly-used keys are: <tt>url</tt> and <tt>serialization</tt>. The
<tt>url</tt> key is required to interact with the Phoenix Query Server.</p>
+ <p>The simplest URL is:</p>
+ <p><tt>jdbc:phoenix:thin:url=http://localhost:8765</tt></p>
+ <p>Where as very complicated URL is:</p>
+
<p><tt>jdbc:phoenix:thin:url=http://queryserver.domain:8765;serialization=PROTOBUF;authentication=SPENGO;[email protected];keytab=/etc/security/keytabs/phoenix.keytab</tt></p>
+ <p>Please refer to the <a class="externalLink"
href="https://calcite.apache.org/avatica/docs/client_reference.html">Apache
Avatica documentation</a> for a full list of supported options in the Thin
client JDBC URL, or see the <a href="server.html">Query Server
documentation</a></p>
+ </div>
+ </div>
+ <div class="section">
+ <h3 id="Is_there_a_way_to_bulk_load_in_Phoenix">Is there a way to bulk load
in Phoenix?</h3>
+ <p><b>Map Reduce</b></p>
+ <p>See the example <a href="bulk_dataload.html">here</a></p>
+ <p><b>CSV</b></p>
+ <p>CSV data can be bulk loaded with built in utility named psql. Typical
upsert rates are 20K - 50K rows per second (depends on how wide are the
rows).</p>
+ <p>Usage example:<br />Create table using psql <tt>$ psql.py [zookeeper]
../examples/web_stat.sql</tt> </p>
+ <p>Upsert CSV bulk data <tt>$ psql.py [zookeeper]
../examples/web_stat.csv</tt></p>
+ </div>
+ <div class="section">
+ <h3 id="How_I_map_Phoenix_table_to_an_existing_HBase_table">How I map
Phoenix table to an existing HBase table?</h3>
+ <p>You can create both a Phoenix table or view through the CREATE
TABLE/CREATE VIEW DDL statement on a pre-existing HBase table. In both cases,
weâll leave the HBase metadata as-is. For CREATE TABLE, weâll create any
metadata (table, column families) that doesnât already exist. Weâll also
add an empty key value for each row so that queries behave as expected (without
requiring all columns to be projected during scans).</p>
+ <p>The other caveat is that the way the bytes were serialized must match the
way the bytes are serialized by Phoenix. For VARCHAR,CHAR, and UNSIGNED_*
types, we use the HBase Bytes methods. The CHAR type expects only single-byte
characters and the UNSIGNED types expect values greater than or equal to zero.
For signed types(TINYINT, SMALLINT, INTEGER and BIGINT), Phoenix will flip the
first bit so that negative values will sort before positive values. Because
HBase sorts row keys in lexicographical order and negative valueâs first bit
is 1 while positive 0 so that negative value is âgreater thanâ positive
value if we donât flip the first bit. So if you stored integers by HBase
native API and want to access them by Phoenix, make sure that all your data
types are UNSIGNED types.</p>
+ <p>Our composite row keys are formed by simply concatenating the values
together, with a zero byte character used as a separator after a variable
length type.</p>
+ <p>If you create an HBase table like this:</p>
+ <p><tt>create 't1', {NAME => 'f1', VERSIONS => 5}</tt></p>
+ <p>then you have an HBase table with a name of ât1â and a column family
with a name of âf1â. Remember, in HBase, you donât model the possible
KeyValues or the structure of the row key. This is the information you specify
in Phoenix above and beyond the table and column family.</p>
+ <p>So in Phoenix, youâd create a view like this:</p>
+ <p><tt>CREATE VIEW "t1" ( pk VARCHAR PRIMARY KEY,
"f1".val VARCHAR )</tt></p>
+ <p>The âpkâ column declares that your row key is a VARCHAR (i.e. a
string) while the âf1â.val column declares that your HBase table will
contain KeyValues with a column family and column qualifier of âf1â:VAL and
that their value will be a VARCHAR.</p>
+ <p>Note that you donât need the double quotes if you create your HBase
table with all caps names (since this is how Phoenix normalizes strings, by
upper casing them). For example, with:</p>
+ <p><tt>create 'T1', {NAME => 'F1', VERSIONS => 5}</tt></p>
+ <p>you could create this Phoenix view:</p>
+ <p><tt>CREATE VIEW t1 ( pk VARCHAR PRIMARY KEY, f1.val VARCHAR )</tt></p>
+ <p>Or if youâre creating new HBase tables, just let Phoenix do everything
for you like this (No need to use the HBase shell at all.):</p>
+ <p><tt>CREATE TABLE t1 ( pk VARCHAR PRIMARY KEY, val VARCHAR )</tt></p>
+ </div>
+ <div class="section">
+ <h3 id="Are_there_any_tips_for_optimizing_Phoenix">Are there any tips for
optimizing Phoenix?</h3>
+ <ul>
+ <li>Use <b>Salting</b> to increase read/write performance Salting can
significantly increase read/write performance by pre-splitting the data into
multiple regions. Although Salting will yield better performance in most
scenarios.</li>
+ </ul>
+ <p>Example:</p>
+ <p><tt>CREATE TABLE TEST (HOST VARCHAR NOT NULL PRIMARY KEY, DESCRIPTION
VARCHAR) SALT_BUCKETS=16</tt></p>
+ <p>Note: Ideally for a 16 region server cluster with quad-core CPUs, choose
salt buckets between 32-64 for optimal performance.</p>
+ <ul>
+ <li><b>Per-split</b> table Salting does automatic table splitting but in
case you want to exactly control where table split occurs with out adding extra
byte or change row key order then you can pre-split a table.</li>
+ </ul>
+ <p>Example: </p>
+ <p><tt>CREATE TABLE TEST (HOST VARCHAR NOT NULL PRIMARY KEY, DESCRIPTION
VARCHAR) SPLIT ON ('CS','EU','NA')</tt></p>
+ <ul>
+ <li>Use <b>multiple column families</b></li>
+ </ul>
+ <p>Column family contains related data in separate files. If you query use
selected columns then it make sense to group those columns together in a column
family to improve read performance.</p>
+ <p>Example:</p>
+ <p>Following create table DDL will create two column faimiles A and B.</p>
+ <p><tt>CREATE TABLE TEST (MYKEY VARCHAR NOT NULL PRIMARY KEY, A.COL1
VARCHAR, A.COL2 VARCHAR, B.COL3 VARCHAR)</tt></p>
+ <ul>
+ <li>Use <b>compression</b> On disk compression improves performance on
large tables</li>
+ </ul>
+ <p>Example: </p>
+ <p><tt>CREATE TABLE TEST (HOST VARCHAR NOT NULL PRIMARY KEY, DESCRIPTION
VARCHAR) COMPRESSION='GZ'</tt></p>
+ <ul>
+ <li> <p>Create <b>indexes</b> See <a
href="#How_do_I_create_Secondary_Index_on_a_table">#How_do_I_create_Secondary_Index_on_a_table</a></p></li>
+ <li> <p><b>Optimize cluster</b> parameters See <a class="externalLink"
href="http://hbase.apache.org/book/performance.html">http://hbase.apache.org/book/performance.html</a></p></li>
+ <li> <p><b>Optimize Phoenix</b> parameters See <a
href="tuning.html">tuning.html</a></p></li>
+ </ul>
+ </div>
+ <div class="section">
+ <h3 id="How_do_I_create_Secondary_Index_on_a_table">How do I create
Secondary Index on a table?</h3>
+ <p>Starting with Phoenix version 2.1, Phoenix supports index over mutable
and immutable data. Note that Phoenix 2.0.x only supports Index over immutable
data. Index write performance index with immutable table is slightly faster
than mutable table however data in immutable table cannot be updated.</p>
+ <p>Example</p>
+ <ul>
+ <li>Create table</li>
+ </ul>
+ <p>Immutable table: <tt>create table test (mykey varchar primary key, col1
varchar, col2 varchar) IMMUTABLE_ROWS=true;</tt></p>
+ <p>Mutable table: <tt>create table test (mykey varchar primary key, col1
varchar, col2 varchar);</tt></p>
+ <ul>
+ <li>Creating index on col2</li>
+ </ul>
+ <p><tt>create index idx on test (col2)</tt></p>
+ <ul>
+ <li>Creating index on col1 and a covered index on col2</li>
+ </ul>
+ <p><tt>create index idx on test (col1) include (col2)</tt></p>
+ <p>Upsert rows in this test table and Phoenix query optimizer will choose
correct index to use. You can see in <a
href="language/index.html#explain">explain plan</a> if Phoenix is using the
index table. You can also give a <a href="language/index.html#hint">hint</a> in
Phoenix query to use a specific index.</p>
+ </div>
+ <div class="section">
+ <h3 id="Why_isnt_my_secondary_index_being_used">Why isnât my secondary
index being used?</h3>
+ <p>The secondary index wonât be used unless all columns used in the query
are in it ( as indexed or covered columns). All columns making up the primary
key of the data table will automatically be included in the index.</p>
+ <p>Example: DDL <tt>create table usertable (id varchar primary key,
firstname varchar, lastname varchar); create index idx_name on usertable
(firstname);</tt></p>
+ <p>Query: DDL <tt>select id, firstname, lastname from usertable where
firstname = 'foo';</tt></p>
+ <p>Index would not be used in this case as lastname is not part of indexed
or covered column. This can be verified by looking at the explain plan. To fix
this create index that has either lastname part of index or covered column.
Example: <tt>create idx_name on usertable (firstname) include
(lastname);</tt></p>
+ </div>
+ <div class="section">
+ <h3 id="How_fast_is_Phoenix_Why_is_it_so_fast">How fast is Phoenix? Why is
it so fast?</h3>
+ <p>Phoenix is fast. Full table scan of 100M rows usually completes in 20
seconds (narrow table on a medium sized cluster). This time come down to few
milliseconds if query contains filter on key columns. For filters on non-key
columns or non-leading key columns, you can add index on these columns which
leads to performance equivalent to filtering on key column by making copy of
table with indexed column(s) part of key.</p>
+ <p>Why is Phoenix fast even when doing full scan:</p>
+ <ol style="list-style-type: decimal">
+ <li>Phoenix chunks up your query using the region boundaries and runs them
in parallel on the client using a configurable number of threads</li>
+ <li>The aggregation will be done in a coprocessor on the server-side,
collapsing the amount of data that gets returned back to the client rather than
returning it all.</li>
+ </ol>
+ </div>
+ <div class="section">
+ <h3 id="How_do_I_connect_to_secure_HBase_cluster">How do I connect to secure
HBase cluster?</h3>
+ <p>Check out excellent post by Anil Gupta <a class="externalLink"
href="http://bigdatanoob.blogspot.com/2013/09/connect-phoenix-to-secure-hbase-cluster.html">http://bigdatanoob.blogspot.com/2013/09/connect-phoenix-to-secure-hbase-cluster.html</a></p>
+ </div>
+ <div class="section">
+ <h3 id="How_do_I_connect_with_HBase_running_on_Hadoop-2">How do I connect
with HBase running on Hadoop-2?</h3>
+ <p>Hadoop-2 profile exists in Phoenix pom.xml. </p>
+ </div>
+ <div class="section">
+ <h3
id="Can_phoenix_work_on_tables_with_arbitrary_timestamp_as_flexible_as_HBase_API">Can
phoenix work on tables with arbitrary timestamp as flexible as HBase API?</h3>
+ <p>By default, Phoenix letâs HBase manage the timestamps and just shows
you the latest values for everything. However, Phoenix also allows arbitrary
timestamps to be supplied by the user. To do that youâd specify a
âCurrentSCNâ at connection time, like this:</p>
+ <div class="source">
+ <pre>Properties props = new Properties();
+props.setProperty("CurrentSCN", Long.toString(ts));
+Connection conn = DriverManager.connect(myUrl, props);
+
+conn.createStatement().execute("UPSERT INTO myTable VALUES ('a')");
+conn.commit();
+</pre>
+ </div>
+ <p>The above is equivalent to doing this with the HBase API:</p>
+ <div class="source">
+ <pre>myTable.put(Bytes.toBytes('a'),ts);
+</pre>
+ </div>
+ <p>By specifying a CurrentSCN, youâre telling Phoenix that you want
everything for that connection to be done at that timestamp. Note that this
applies to queries done on the connection as well - for example, a query over
myTable above would not see the data it just upserted, since it only sees data
that was created before its CurrentSCN property. This provides a way of doing
snapshot, flashback, or point-in-time queries.</p>
+ <p>Keep in mind that creating a new connection is <i>not</i> an expensive
operation. The same underlying HConnection is used for all connections to the
same cluster, so itâs more or less like instantiating a few objects.</p>
+ </div>
+ <div class="section">
+ <h3 id="Why_isnt_my_query_doing_a_RANGE_SCAN">Why isnât my query doing a
RANGE SCAN?</h3>
+ <p><tt>DDL: CREATE TABLE TEST (pk1 char(1) not null, pk2 char(1) not null,
pk3 char(1) not null, non-pk varchar CONSTRAINT PK PRIMARY KEY(pk1, pk2,
pk3));</tt></p>
+ <p>RANGE SCAN means that only a subset of the rows in your table will be
scanned over. This occurs if you use one or more leading columns from your
primary key constraint. Query that is not filtering on leading PK columns ex.
<tt>select * from test where pk2='x' and pk3='y';</tt> will result in full scan
whereas the following query will result in range scan <tt>select * from test
where pk1='x' and pk2='y';</tt>. Note that you can add a secondary index on
your âpk2â and âpk3â columns and that would cause a range scan to be
done for the first query (over the index table).</p>
+ <p>DEGENERATE SCAN means that a query canât possibly return any rows. If
we can determine that at compile time, then we donât bother to even run the
scan.</p>
+ <p>FULL SCAN means that all rows of the table will be scanned over
(potentially with a filter applied if you have a WHERE clause)</p>
+ <p>SKIP SCAN means that either a subset or all rows in your table will be
scanned over, however it will skip large groups of rows depending on the
conditions in your filter. See <a class="externalLink"
href="http://phoenix-hbase.blogspot.com/2013/05/demystifying-skip-scan-in-phoenix.html">this</a>
blog for more detail. We donât do a SKIP SCAN if you have no filter on the
leading primary key columns, but you can force a SKIP SCAN by using the /<i>+
SKIP_SCAN </i>/ hint. Under some conditions, namely when the cardinality of
your leading primary key columns is low, it will be more efficient than a FULL
SCAN.</p>
+ </div>
+ <div class="section">
+ <h3 id="Should_I_pool_Phoenix_JDBC_Connections">Should I pool Phoenix JDBC
Connections?</h3>
+ <p>No, it is not necessary to pool Phoenix JDBC Connections.</p>
+ <p>Phoenixâs Connection objects are different from most other JDBC
Connections due to the underlying HBase connection. The Phoenix Connection
object is designed to be a thin object that is inexpensive to create. If
Phoenix Connections are reused, it is possible that the underlying HBase
connection is not always left in a healthy state by the previous user. It is
better to create new Phoenix Connections to ensure that you avoid any potential
issues.</p>
+ <p>Implementing pooling for Phoenix could be done simply by creating a
delegate Connection that instantiates a new Phoenix connection when retrieved
from the pool and then closes the connection when returning it to the pool (see
<a class="externalLink"
href="https://issues.apache.org/jira/browse/PHOENIX-2388">PHOENIX-2388</a>).</p>
+ </div>
+ <div class="section">
+ <h3 id="Why_empty_key_value">Why does Phoenix add an empty/dummy KeyValue
when doing an upsert?<a
name="Why_does_Phoenix_add_an_emptydummy_KeyValue_when_doing_an_upsert"></a></h3>
+ <p>The empty or dummy KeyValue (with a column qualifier of _0) is needed to
ensure that a given column is available for all rows.</p>
+ <p>As you may know, data is stored in HBase as KeyValues, meaning that the
full row key is stored for each column value. This also implies that the row
key is not stored at all unless there is at least one column stored.</p>
+ <p>Now consider JDBC row which has an integer primary key, and several
columns which are all null. In order to be able to store the primary key, a
KeyValue needs to be stored to show that the row is present at all. This column
is represented by the empty column that youâve noticed. This allows doing a
âSELECT * FROM TABLEâ and receiving records for all rows, even those whose
non-pk columns are null.</p>
+ <p>The same issue comes up even if only one column is null for some (or all)
records. A scan over Phoenix will include the empty column to ensure that rows
that only consist of the primary key (and have null for all non-key columns)
will be included in a scan result.</p>
+ </div>
+</div>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ </div><!-- /container -->
+
+ <!-- Footer
+ ================================================== -->
+ <footer class="well">
+ <div class="container">
+ <div class="row">
+ <div class="span2 bottom-nav">
+ <ul class="nav nav-list">
+ <li
class="nav-header">About</li>
+ <li >
+ <a href="index.html"
title="Overview">Overview</a>
+ </li>
+ <li >
+ <a
href="who_is_using.html" title="Who is Using">Who is Using</a>
+ </li>
+ <li >
+ <a href="recent.html"
title="Recent Improvements">Recent Improvements</a>
+ </li>
+ <li >
+ <a href="roadmap.html"
title="Roadmap">Roadmap</a>
+ </li>
+ <li >
+ <a href="news.html"
title="News">News</a>
+ </li>
+ <li >
+ <a
href="performance.html" title="Performance">Performance</a>
+ </li>
+ <li >
+ <a href="team.html"
title="Team">Team</a>
+ </li>
+ <li >
+ <a
href="resources.html" title="Presentations">Presentations</a>
+ </li>
+ <li >
+ <a
href="mailing_list.html" title="Mailing Lists">Mailing Lists</a>
+ </li>
+ <li >
+ <a href="source.html"
title="Source Repository">Source Repository</a>
+ </li>
+ <li >
+ <a href="issues.html"
title="Issue Tracking">Issue Tracking</a>
+ </li>
+ <li >
+ <a href="download.html"
title="Download">Download</a>
+ </li>
+ <li >
+ <a
href="installation.html" title="Installation">Installation</a>
+ </li>
+ <li >
+ <a href="http:divider"
title=""></a>
+ </li>
+ <li >
+ <a
href="contributing.html" title="How to Contribute">How to Contribute</a>
+ </li>
+ <li >
+ <a href="develop.html"
title="How to Develop">How to Develop</a>
+ </li>
+ <li >
+ <a
href="building_website.html" title="How to Update Website">How to Update
Website</a>
+ </li>
+ <li >
+ <a href="release.html"
title="How to Release">How to Release</a>
+ </li>
+ <li >
+ <a href="http:divider"
title=""></a>
+ </li>
+ <li >
+ <a
href="http://www.apache.org/licenses/" title="License"
class="externalLink">License</a>
+ </li>
+ </ul>
+ </div>
+ <div class="span2 bottom-nav">
+ <ul class="nav nav-list">
+ <li
class="nav-header">Using</li>
+ <li class="active">
+ <a href="#"
title="F.A.Q.">F.A.Q.</a>
+ </li>
+ <li >
+ <a
href="Phoenix-in-15-minutes-or-less.html" title="Quick Start">Quick Start</a>
+ </li>
+ <li >
+ <a href="building.html"
title="Building">Building</a>
+ </li>
+ <li >
+ <a
href="tuning_guide.html" title="Tuning">Tuning</a>
+ </li>
+ <li >
+ <a
href="explainplan.html" title="Explain Plan">Explain Plan</a>
+ </li>
+ <li >
+ <a href="tuning.html"
title="Configuration">Configuration</a>
+ </li>
+ <li >
+ <a
href="upgrading.html" title="Backward Compatibility">Backward Compatibility</a>
+ </li>
+ <li >
+ <a
href="release_notes.html" title="Release Notes">Release Notes</a>
+ </li>
+ <li >
+ <a href="pherf.html"
title="Performance Testing">Performance Testing</a>
+ </li>
+ <li >
+ <a href="http:divider"
title=""></a>
+ </li>
+ <li >
+ <a
href="phoenix_spark.html" title="Apache Spark Integration">Apache Spark
Integration</a>
+ </li>
+ <li >
+ <a
href="hive_storage_handler.html" title="Phoenix Storage Handler for Apache
Hive">Phoenix Storage Handler for Apache Hive</a>
+ </li>
+ <li >
+ <a
href="pig_integration.html" title="Apache Pig Integration">Apache Pig
Integration</a>
+ </li>
+ <li >
+ <a
href="phoenix_mr.html" title="Map Reduce Integration">Map Reduce Integration</a>
+ </li>
+ <li >
+ <a href="flume.html"
title="Apache Flume Plugin">Apache Flume Plugin</a>
+ </li>
+ <li >
+ <a href="kafka.html"
title="Apache Kafka Plugin">Apache Kafka Plugin</a>
+ </li>
+ <li >
+ <a href="python.html"
title="Python Driver">Python Driver</a>
+ </li>
+ </ul>
+ </div>
+ <div class="span2 bottom-nav">
+ <ul class="nav nav-list">
+ <li
class="nav-header">Features</li>
+ <li >
+ <a
href="transactions.html" title="Transactions">Transactions</a>
+ </li>
+ <li >
+ <a href="udf.html"
title="User-defined Functions">User-defined Functions</a>
+ </li>
+ <li >
+ <a href="http:divider"
title=""></a>
+ </li>
+ <li >
+ <a
href="secondary_indexing.html" title="Secondary Indexes">Secondary Indexes</a>
+ </li>
+ <li >
+ <a
href="columnencoding.html" title="Storage Formats">Storage Formats</a>
+ </li>
+ <li >
+ <a
href="atomic_upsert.html" title="Atomic Upsert">Atomic Upsert</a>
+ </li>
+ <li >
+ <a
href="namspace_mapping.html" title="Namespace Mapping">Namespace Mapping</a>
+ </li>
+ <li >
+ <a
href="update_statistics.html" title="Statistics Collection">Statistics
Collection</a>
+ </li>
+ <li >
+ <a
href="rowtimestamp.html" title="Row Timestamp Column">Row Timestamp Column</a>
+ </li>
+ <li >
+ <a href="paged.html"
title="Paged Queries">Paged Queries</a>
+ </li>
+ <li >
+ <a href="salted.html"
title="Salted Tables">Salted Tables</a>
+ </li>
+ <li >
+ <a
href="skip_scan.html" title="Skip Scan">Skip Scan</a>
+ </li>
+ <li >
+ <a
href="tablesample.html" title="Table Sampling">Table Sampling</a>
+ </li>
+ <li >
+ <a href="http:divider"
title=""></a>
+ </li>
+ <li >
+ <a href="views.html"
title="Views">Views</a>
+ </li>
+ <li >
+ <a
href="multi-tenancy.html" title="Multi tenancy">Multi tenancy</a>
+ </li>
+ <li >
+ <a
href="dynamic_columns.html" title="Dynamic Columns">Dynamic Columns</a>
+ </li>
+ <li >
+ <a href="http:divider"
title=""></a>
+ </li>
+ <li >
+ <a
href="bulk_dataload.html" title="Bulk Loading">Bulk Loading</a>
+ </li>
+ <li >
+ <a href="server.html"
title="Query Server">Query Server</a>
+ </li>
+ <li >
+ <a href="metrics.html"
title="Metrics">Metrics</a>
+ </li>
+ <li >
+ <a href="tracing.html"
title="Tracing">Tracing</a>
+ </li>
+ <li >
+ <a href="cursors.html"
title="Cursor">Cursor</a>
+ </li>
+ </ul>
+ </div>
+ <div class="span3 bottom-nav">
+ <ul class="nav nav-list">
+ <li
class="nav-header">Reference</li>
+ <li >
+ <a
href="language/index.html" title="Grammar">Grammar</a>
+ </li>
+ <li >
+ <a
href="language/functions.html" title="Functions">Functions</a>
+ </li>
+ <li >
+ <a
href="language/datatypes.html" title="Datatypes">Datatypes</a>
+ </li>
+ <li >
+ <a
href="array_type.html" title="ARRAY type">ARRAY type</a>
+ </li>
+ <li >
+ <a href="http:divider"
title=""></a>
+ </li>
+ <li >
+ <a
href="sequences.html" title="Sequences">Sequences</a>
+ </li>
+ <li >
+ <a href="joins.html"
title="Joins">Joins</a>
+ </li>
+ <li >
+ <a
href="subqueries.html" title="Subqueries">Subqueries</a>
+ </li>
+ <li >
+ <a
href="explainplan.html" title="Explain Plan">Explain Plan</a>
+ </li>
+ </ul>
+ </div>
+ <div class="span3 bottom-description">
+ <form
action="http://search-hadoop.com/?" method="get"><input value="Phoenix"
name="fc_project" type="hidden"><input placeholder="Search Phoenix…"
required="required" style="width:170px;" size="18" name="q" id="query"
type="search"></form>
+ </div>
+ </div>
+ </div>
+ </footer>
+
+ <div class="container subfooter">
+ <div class="row">
+ <div class="span12">
+ <p class="pull-right"><a href="#">Back to
top</a></p>
+ <p class="copyright">Copyright ©2020 <a
href="http://www.apache.org">Apache Software Foundation</a>. All Rights
Reserved.</p>
+ </div>
+ </div>
+ </div>
+
+ <!-- Le javascript
+ ================================================== -->
+ <!-- Placed at the end of the document so the pages load faster -->
+ <script
src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
+
+ <script
src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
+ <script src="./js/lightbox.js"></script>
+ <script src="./js/jquery.smooth-scroll.min.js"></script>
+ <!-- back button support for smooth scroll -->
+ <script src="./js/jquery.ba-bbq.min.js"></script>
+ <script src="//yandex.st/highlightjs/7.5/highlight.min.js"></script>
+
+ <script src="./js/reflow-skin.js"></script>
+
+ </body>
+</html>
Modified: phoenix/site/publish/language/datatypes.html
URL:
http://svn.apache.org/viewvc/phoenix/site/publish/language/datatypes.html?rev=1872559&r1=1872558&r2=1872559&view=diff
==============================================================================
--- phoenix/site/publish/language/datatypes.html (original)
+++ phoenix/site/publish/language/datatypes.html Thu Jan 9 16:46:20 2020
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<!--
- Generated by Apache Maven Doxia at 2020-01-07
+ Generated by Apache Maven Doxia at 2020-01-09
Rendered using Reflow Maven Skin 1.1.0
(http://andriusvelykis.github.io/reflow-maven-skin)
-->
<html xml:lang="en" lang="en">
Modified: phoenix/site/publish/language/functions.html
URL:
http://svn.apache.org/viewvc/phoenix/site/publish/language/functions.html?rev=1872559&r1=1872558&r2=1872559&view=diff
==============================================================================
--- phoenix/site/publish/language/functions.html (original)
+++ phoenix/site/publish/language/functions.html Thu Jan 9 16:46:20 2020
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<!--
- Generated by Apache Maven Doxia at 2020-01-07
+ Generated by Apache Maven Doxia at 2020-01-09
Rendered using Reflow Maven Skin 1.1.0
(http://andriusvelykis.github.io/reflow-maven-skin)
-->
<html xml:lang="en" lang="en">
Modified: phoenix/site/publish/language/index.html
URL:
http://svn.apache.org/viewvc/phoenix/site/publish/language/index.html?rev=1872559&r1=1872558&r2=1872559&view=diff
==============================================================================
--- phoenix/site/publish/language/index.html (original)
+++ phoenix/site/publish/language/index.html Thu Jan 9 16:46:20 2020
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<!--
- Generated by Apache Maven Doxia at 2020-01-07
+ Generated by Apache Maven Doxia at 2020-01-09
Rendered using Reflow Maven Skin 1.1.0
(http://andriusvelykis.github.io/reflow-maven-skin)
-->
<html xml:lang="en" lang="en">
Modified: phoenix/site/source/src/site/markdown/faq.md
URL:
http://svn.apache.org/viewvc/phoenix/site/source/src/site/markdown/faq.md?rev=1872559&r1=1872558&r2=1872559&view=diff
==============================================================================
--- phoenix/site/source/src/site/markdown/faq.md (original)
+++ phoenix/site/source/src/site/markdown/faq.md Thu Jan 9 16:46:20 2020
@@ -222,7 +222,7 @@ Example:
` CREATE TABLE TEST (HOST VARCHAR NOT NULL PRIMARY KEY, DESCRIPTION VARCHAR)
COMPRESSION='GZ'`
* Create **indexes**
-See
[faq.html#/How_do_I_create_Secondary_Index_on_a_table](faq.html#/How_do_I_create_Secondary_Index_on_a_table)
+See
[#How_do_I_create_Secondary_Index_on_a_table](#How_do_I_create_Secondary_Index_on_a_table)
* **Optimize cluster** parameters
See http://hbase.apache.org/book/performance.html