You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Andres de la Peña (Jira)" <ji...@apache.org> on 2025/02/28 13:01:00 UTC

[jira] [Commented] (CASSANDRA-18112) Support manual secondary index selection at the CQL level

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

Andres de la Peña commented on CASSANDRA-18112:
-----------------------------------------------

Regarding the syntax, I think it's not necessary to add the keyspace to the index names, since it can be taken from the table name in the `FROM` part of the query:
{code:java}
SELECT ... FROM ... WHERE ... 
   WITH OPTIONS = { 'exclude_indexes' : [<idx1>, <idx2>], 'include_indexes' : [<idx3>, <idx4>]}
{code}
Also, I think we might have more not-index query options in the future, and the {{WITH ... AND ...}} syntax seems meant to support different groups of query options, so I wonder if using {{OPTIONS}} might be too generic if we want to add a new group of unrelated options in the future. We might use something a bit more specific, like:
{code:java}
SELECT ... FROM ... WHERE ... 
   WITH INDEX_OPTIONS = { 'exclude' : [<idx1>, <idx2>], 'include' : [<idx3>, <idx4>]}
{code}
Or perhaps:
{code:java}
SELECT ... FROM ... WHERE ... 
   WITH INDEXES = { 'exclude' : [<idx1>, <idx2>], 'include' : [<idx3>, <idx4>]}
{code}
 Regarding the corner cases mentioned above:
{quote}1.) What happens when we mention a non-existent index?
{quote}
I also think we should reject the query. The same applies if the index is not available.
{quote}2.) What should happen when we exclude all the indexes that could be used for a query?
{quote}
Rather than fail, I would let it pass depending on whether it satisfies the `ALLOW FILTERING` requirements (and the AF flag is used).
{quote}3.) Should we provide a simple syntax for single-index exclusions, or just go with a list-based format for everything?
{quote}
I think I would go for the list-based format for the first version, we can always add shortcuts later.

Regarding how to send these index selections to the replicas, I think we would need to improve how the {{Index.QueryPlan}} is serialized. Currently, we only serialize the metadata of one of the indexes in the plan. Then, the replicas take the {{Index.Group}} of this plan and build a new {{Index.QueryPlan}} from scratch (see [here|https://github.com/apache/cassandra/blob/773b3a391155d39bc6f65422d4990b1179d3108d/src/java/org/apache/cassandra/db/ReadCommand.java#L1302-L1306]). This means that the replicas can have different index selections than the coordinator. This can be problematic for {{ALLOW FILTERING}} validation if any of the indexes has become unavailable between coordinator-side validation and replica-side planning. So, I think that it would be nice to send the list of candidate indexes to the replicas, independently of this feature. If we put everything together, there would be three lists of indexes to be sent to the replicas:
 * Indexes that can be used, accordingly to the query expressions.
 * Indexes that should be used, accordingly to the query options.
 * Indexes that shouldn't be used, accordingly to the query options.

This can be simplified to just:
 * Indexes that can be used if the replica thinks it's worth it.
 * Indexes that should be used no matter what.

 

> Support manual secondary index selection at the CQL level
> ---------------------------------------------------------
>
>                 Key: CASSANDRA-18112
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-18112
>             Project: Apache Cassandra
>          Issue Type: Improvement
>          Components: CQL/Syntax, Feature/SAI, Legacy/CQL
>            Reporter: guo Maxwell
>            Assignee: Caleb Rackliffe
>            Priority: Normal
>             Fix For: 5.x
>
>         Attachments: ci_summary.html
>
>
> It seems that  CQL do not have the ability of INDEX HINT , such as when we have more than one secondary index for some data table,And if the query hit the indexes, the index with more estimate rows will be returned. But if we want the query to be executed under our willing , we can use a hint like ,hint specified index or ignore the index.
> At first I want to open a jira that to add the feature of hint for CQL ,But I think that may be  a gigantic task with no clear goal.
> Besides I think there may need a DISSCUSS for the specific grammatical form before starting the work.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org