Shubham Roy created PHOENIX-8032:
------------------------------------

             Summary: Support SPLIT ON in CREATE CDC to pre-split the CDC index
                 Key: PHOENIX-8032
                 URL: https://issues.apache.org/jira/browse/PHOENIX-8032
             Project: Phoenix
          Issue Type: Improvement
            Reporter: Shubham Roy
            Assignee: Shubham Roy
             Fix For: 5.4.0, 5.3.3


h3. Problem

{{CREATE TABLE}} and {{CREATE INDEX}} accept {{SPLIT ON}}, but {{CREATE CDC}} 
does not. The uncovered index behind a CDC is always created with a single 
region, so every CDC index write lands on that one region until it splits by 
size. On large, write-heavy tables, that region becomes a hotspot as soon as 
CDC is enabled.

h3. Proposal

Accept an optional {{SPLIT ON}} clause after the CDC properties, in the same 
position as in {{CREATE TABLE}} and {{CREATE INDEX}}, and use it to pre-split 
the CDC index.

{code:sql}
CREATE CDC [IF NOT EXISTS] cdc_name ON table_ref
    [INCLUDE (change_scope [, ...])]
    [property [, ...]]
    [SPLIT ON (split_point [, ...])]

-- example
CREATE CDC my_cdc ON my_table SPLIT ON ('4', '8', 'c')
{code}

* Split points apply to the CDC index row key: {{PARTITION_ID()}}—the data 
table region's encoded name, consisting of 32 lowercase hexadecimal 
characters—followed by {{PHOENIX_ROW_TIMESTAMP()}} and the data table primary 
key. Multi-tenant tables put {{TENANT_ID}} first.
* Split points can be constants or bind parameters, as in {{CREATE TABLE}}. 
Bind handling pre-splits the index using exactly those bytes.
* A CDC on a view keeps its index in the shared view index table, which does 
not accept user-supplied split points. The clause is accepted there but has no 
effect, matching the behavior of {{CREATE INDEX ... SPLIT ON}} on a view.

h3. Testing

* {{QueryParserTest#testCreateCDCWithSplitPoints}}: Verify parsing, clause 
order, and bind count.
* {{CDCDefinitionIT#testCreateCDCWithSplitPoints}}: Verify that the CDC index 
regions match a mix of literal and raw-byte bind split points.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to