maedhroz commented on code in PR #4150: URL: https://github.com/apache/cassandra/pull/4150#discussion_r2085864979
########## test/distributed/org/apache/cassandra/distributed/test/sai/StrictFilteringTest.java: ########## @@ -216,6 +218,26 @@ public void testShortReadWithRegularColumns() assertRows(initialRows, row(0, 1, 2)); } + @Test + public void testNoShortReadAtLimit() + { + CLUSTER.schemaChange(withKeyspace("CREATE TABLE %s.short_read_no_srp (k int, c int, a int, PRIMARY KEY (k, c)) WITH read_repair = 'NONE'")); + CLUSTER.schemaChange(withKeyspace("CREATE INDEX ON %s.short_read_no_srp(a) USING 'sai'")); + SAIUtil.waitForIndexQueryable(CLUSTER, KEYSPACE); + + CLUSTER.get(1).executeInternal(withKeyspace("INSERT INTO %s.short_read_no_srp(k, c, a) VALUES (0, 2, 1) USING TIMESTAMP 5")); + CLUSTER.get(2).executeInternal(withKeyspace("INSERT INTO %s.short_read_no_srp(k, c, a) VALUES (0, 3, 1) USING TIMESTAMP 6")); + + Long srpRequestsBefore = CLUSTER.get(1).callOnInstance(() -> Keyspace.open(KEYSPACE).getColumnFamilyStore("short_read_no_srp").metric.shortReadProtectionRequests.getCount()); + + String select = withKeyspace("SELECT * FROM %s.short_read_no_srp WHERE k = 0 AND a = 1 LIMIT 1"); + Iterator<Object[]> initialRows = CLUSTER.coordinator(1).executeWithPaging(select, ConsistencyLevel.ALL, 2); + assertRows(initialRows, row(0, 2, 1)); Review Comment: Imagine a partition with 10,000 rows, 100 of which are matches for an index or filtering query. With a limit of 10, the logic before this patch would have to keep issuing SRP reads to find all 100 matches, which kills performance...almost to a comical extent. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org For additional commands, e-mail: pr-h...@cassandra.apache.org