From issues-return-3971-archive-asf-public=cust-asf.ponee.io@phoenix.apache.org Fri Jan 11 01:59:04 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 1202918062A for ; Fri, 11 Jan 2019 01:59:03 +0100 (CET) Received: (qmail 89324 invoked by uid 500); 11 Jan 2019 00:59:03 -0000 Mailing-List: contact issues-help@phoenix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@phoenix.apache.org Delivered-To: mailing list issues@phoenix.apache.org Received: (qmail 89305 invoked by uid 99); 11 Jan 2019 00:59:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Jan 2019 00:59:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 962B1C0333 for ; Fri, 11 Jan 2019 00:59:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -109.501 X-Spam-Level: X-Spam-Status: No, score=-109.501 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id JM6UsOaK1NDX for ; Fri, 11 Jan 2019 00:59:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 146625F20B for ; Fri, 11 Jan 2019 00:59:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 6B55BE2651 for ; Fri, 11 Jan 2019 00:59:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 186C92557E for ; Fri, 11 Jan 2019 00:59:00 +0000 (UTC) Date: Fri, 11 Jan 2019 00:59:00 +0000 (UTC) From: "Vincent Poon (JIRA)" To: issues@phoenix.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (PHOENIX-5095) Support INTERLEAVE of parent and child tables MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/PHOENIX-5095?page=3Dcom.atlassi= an.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D16= 739907#comment-16739907 ]=20 Vincent Poon edited comment on PHOENIX-5095 at 1/11/19 12:58 AM: ----------------------------------------------------------------- Hm, in my example above, select on the view returns columns from Singers.= =C2=A0 To avoid that, we need to create a base table separate from both, an= d create the parent as a view as well. CREATE TABLE IF NOT EXISTS SingersBase (SingerId BIGINT NOT NULL,Delimiter = CHAR(10) NOT NULL,CONSTRAINT PK PRIMARY KEY(SingerId,Delimiter)); CREATE VIEW Singers (FirstName VARCHAR, LastName VARCHAR) AS SELECT * from= SingersBase where Delimiter =3D 'Singers'; This returns 'Delimiter' in the results, though. Perhaps we can delimit by putting the view in a different column family was (Author: vincentpoon): Hm, in my example above, select on the view returns columns from Singers.= =C2=A0 To avoid that, we need to create a base table separate from both, an= d create the parent as a view as well. CREATE TABLE IF NOT EXISTS SingersBase (SingerId BIGINT NOT NULL,Delimiter = CHAR(10) NOT NULL,CONSTRAINT PK PRIMARY KEY(SingerId,Delimiter)); CREATE VIEW Singers (FirstName VARCHAR, LastName VARCHAR) AS SELECT * from= SingersBase where Delimiter =3D 'Singers'; This returns 'Delimiter' in the results, though. > Support INTERLEAVE of parent and child tables > --------------------------------------------- > > Key: PHOENIX-5095 > URL: https://issues.apache.org/jira/browse/PHOENIX-5095 > Project: Phoenix > Issue Type: Improvement > Affects Versions: 4.15.0 > Reporter: Vincent Poon > Priority: Major > > Spanner has a concept of [interleaved tables|https://cloud.google.com/spa= nner/docs/schema-and-data-model#creating-interleaved-tables] > I'd like to brainstorm here how to implement this in Phoenix. In general= we want a design that can have > 1) Fast queries against the parent table PK > 2) Fast queries against the child table PK > 3) Fast joins between the parent and child > It seems we can get pretty close to this with views. Views can have thei= r own PK which adds to the rowkey of the base table. However, there doesn'= t seem to be a delimiter to distinguish PKs of different views on the base = table. The closest I could up with is adding a delimiter to the base table= PK, something like: > CREATE TABLE IF NOT EXISTS Singers ( > SingerId BIGINT NOT NULL, > Delimiter CHAR(10) NOT NULL, > FirstName VARCHAR, > CONSTRAINT PK PRIMARY KEY > ( > SingerId, > Delimiter > ) > ); > CREATE VIEW Albums (AlbumId BIGINT PRIMARY KEY, AlbumTitle VARCHAR) AS SE= LECT * from Singers where Delimiter =3D 'Albums'; > We also need to make the JOIN on these tables more intelligent, such that= a single scan can join across parent-child. Perhaps by reading metadata c= reated during INTERLEAVE table creation, so we know we are joining across i= nterleaved tables. > We could also have a custom split policy to avoid splitting in the middle= of an interleaved table (though this might restrict how large your interle= aved child table can be). -- This message was sent by Atlassian JIRA (v7.6.3#76005)