Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 58986200BDB for ; Mon, 12 Dec 2016 17:46:00 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 5754B160B1A; Mon, 12 Dec 2016 16:46:00 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id A07D3160B2A for ; Mon, 12 Dec 2016 17:45:59 +0100 (CET) Received: (qmail 13984 invoked by uid 500); 12 Dec 2016 16:45:58 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 13932 invoked by uid 99); 12 Dec 2016 16:45:58 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Dec 2016 16:45:58 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 852A12C03E7 for ; Mon, 12 Dec 2016 16:45:58 +0000 (UTC) Date: Mon, 12 Dec 2016 16:45:58 +0000 (UTC) From: "Corentin Chary (JIRA)" To: commits@cassandra.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CASSANDRA-12915) SASI: Index intersection can be very inefficient MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Mon, 12 Dec 2016 16:46:00 -0000 [ https://issues.apache.org/jira/browse/CASSANDRA-12915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15742418#comment-15742418 ] Corentin Chary commented on CASSANDRA-12915: -------------------------------------------- To give you some perspective, in my specific use case the queries are user generated and our only safeguard is that we put a limit to the number of generate results (5000). We already process user-provided globs into CQL queries trying to choose the best indexes. But really it would be better if the query optimizer was in the database rather than in our code. I agree that my way of doing things tries to bypass a few things, but it also doesn't seem to create regressions and provides some benefits. I propose that we split the discussion in three parts: 1# Do you see a quick way of fixing the 'empty iterator' issue ? 2# Would you agree to chance the format to include proper cardinality estimation to the index (so we can build upon later) 3# What would be the ETA for a proper query planner ? If O(months), would it make sense to merge something like what I did to bring some performance improvement in the meantime ? Thanks ! > SASI: Index intersection can be very inefficient > ------------------------------------------------ > > Key: CASSANDRA-12915 > URL: https://issues.apache.org/jira/browse/CASSANDRA-12915 > Project: Cassandra > Issue Type: Improvement > Components: sasi > Reporter: Corentin Chary > Fix For: 3.x > > > It looks like RangeIntersectionIterator.java and be pretty inefficient in some cases. Let's take the following query: > SELECT data FROM table WHERE index1 = 'foo' AND index2 = 'bar'; > In this case: > * index1 = 'foo' will match 2 items > * index2 = 'bar' will match ~300k items > On my setup, the query will take ~1 sec, most of the time being spent in disk.TokenTree.getTokenAt(). > if I patch RangeIntersectionIterator so that it doesn't try to do the intersection (and effectively only use 'index1') the query will run in a few tenth of milliseconds. > I see multiple solutions for that: > * Add a static thresold to avoid the use of the index for the intersection when we know it will be slow. Probably when the range size factor is very small and the range size is big. > * CASSANDRA-10765 -- This message was sent by Atlassian JIRA (v6.3.4#6332)