Andres de la Peña created CASSANDRA-17187:
---------------------------------------------

             Summary: Guardrail for SELECT IN terms and their cartesian product
                 Key: CASSANDRA-17187
                 URL: https://issues.apache.org/jira/browse/CASSANDRA-17187
             Project: Cassandra
          Issue Type: New Feature
          Components: Feature/Guardrails
            Reporter: Andres de la Peña


Add a guardrail to limit the number restrictions generated by the cartesian 
product of the {{IN}} restrictions of a {{SELECT}} query, for example:
{code}
# Guardrail to warn or abort when IN query creates a cartesian product with a 
# size exceeding threshold, eg. "a in (1,2,...10) and b in (1,2...10)" results 
in 
# cartesian product of 100.
# The two thresholds default to -1 to disable. 
in_select_cartesian_product:
    warn_threshold: -1
    abort_threshold: -1
{code}
As an example of why this guardrails is proposed, these queries bring a C* 
instance to its knees even before the query starts executing: 
{code}
@Test
public void testPartitionKeyTerms() throws Throwable
{
    createTable("CREATE TABLE %s (pk1 int, pk2 int, pk3 int, pk4 int, pk5 int, 
pk6 int, pk7 int, pk8 int, pk9 int, " +
               "PRIMARY KEY((pk1, pk2, pk3, pk4, pk5, pk6, pk7, pk8, pk9)))");
    execute("SELECT * FROM %s WHERE pk1 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " +
            "AND pk2 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " +
            "AND pk3 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " +
            "AND pk4 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " +
            "AND pk5 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " +
            "AND pk6 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " +
            "AND pk7 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " +
            "AND pk8 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " +
            "AND pk9 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);");
}

@Test
public void testClusteringKeyTerms() throws Throwable
{
    createTable("CREATE TABLE %s (pk int ,ck1 int, ck2 int, ck3 int, ck4 int, 
ck5 int, ck6 int, ck7 int, ck8 int, ck9 int, " +
            "PRIMARY KEY(pk, ck1, ck2, ck3, ck4, ck5, ck6, ck7, ck8, ck9))");
    execute("SELECT * FROM %s WHERE pk = 1 " +
            "AND ck1 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " +
            "AND ck2 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " +
            "AND ck3 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " +
            "AND ck4 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " +
            "AND ck5 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " +
            "AND ck6 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " +
            "AND ck7 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " +
            "AND ck8 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " +
            "AND ck9 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);");
}
{code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to