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

James Taylor commented on PHOENIX-3128:
---------------------------------------

Good catch, [~junegunn].

The first change in MutationState looks correct - we shouldn't be adding local 
index maintainers to that list as that'll cause the client to send over the 
mutations for local indexes. There might be a corner case for IndexTool where 
we're generating HFiles and need to include *all* non disabled indexes (based 
on {{includeMutableIndexes}} which should probably be includeAllIndexes). So 
maybe there should be three separate cases there: includeAllIndexes, 
table.isImmutable(), and other/none case.

The second change in PhoenixIndexCodec isn't quite right - it's a little too 
general. There's a corner case in rollback of transactions that needs to issue 
deletes for local indexes (from MutationState):
{code}
                    // If we have mutable indexes, local immutable indexes, or 
global immutable indexes
                    // that reference key value columns, setup index meta data 
and attach here. In this
                    // case updates to the indexes will be generated on the 
server side.
                    // An alternative would be to let Tephra track the row keys 
for the immutable index
                    // by adding it as a transaction participant (soon we can 
prevent any conflict
                    // detection from occurring) with the downside being the 
additional memory required.
                    if (!keyValueIndexes.isEmpty()) {
                        attachMetaData = true;
                        IndexMaintainer.serializeAdditional(table, 
indexMetaDataPtr, keyValueIndexes, connection);
                    }
                    if (attachMetaData) {
                        cache = setMetaDataOnMutations(tableRef, deletes, 
indexMetaDataPtr);
                    }
{code}

Instead, I think it'd be safe to:
- not call generateDeletes() in PhoenixTransactionalIndexer.processMutation()  
if the table is immutable, and
- not call codec.getIndexDeletes() in NonTxIndexBuilder.addDeleteUpdatesToMap() 
if table is immutable.

Currently we don't support a mix of immutable and mutable indexes, so if the 
first index maintainer has indexMaintainer.isImmutableRows() of true, then we 
know the table is immutable. Slightly more flexible would be to filter the 
indexMaintainers where indexMaintainer.isImmutableRows() is true.

> Remove extraneous operations during upsert with local immutable index
> ---------------------------------------------------------------------
>
>                 Key: PHOENIX-3128
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-3128
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: Junegunn Choi
>            Assignee: Junegunn Choi
>             Fix For: 4.8.0
>
>         Attachments: PHOENIX-3128.patch
>
>
> Upsert to a table with a local immutable index is supposed to be more 
> efficient than to a table with a local mutable index, but it's actually 
> slower (in our environment by 30%) due to extraneous operations involved.
> The problem is twofold:
> 1. Client unnecessarily prepares and sends index update.
> 2. Index cleanup is done regardless of the immutability of the table.



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

Reply via email to