You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Pierre Chalamet <pi...@chalamet.net> on 2012/04/30 22:45:02 UTC

execute_prepared_cql_query and variable range filter parameter

Hi all,

 

Is there a support in Cassandra 1.1 for variable range filter parameter
(sorry I can't find a right name for that):

select * from TestCF where key in (?)

 

using execute_prepared_cql_query ?

 

In the query above, it seems I can only bind one value to '?'.

I mean, if several values are required for '?' then I have to rewrite the
query using several jokers.

 

My problem is that this defeats statement preparation (using
prepare_cql_query).

 

Maybe there is a way to bind an array of values to a single command joker ?

 

Thanks !

- Pierre

 


RE: execute_prepared_cql_query and variable range filter parameter

Posted by Pierre Chalamet <pi...@chalamet.net>.
Sure, here it is : CASSANDRA-4210.

- Pierre

-----Original Message-----
From: Sylvain Lebresne [mailto:sylvain@datastax.com] 
Sent: mercredi 2 mai 2012 09:53
To: user@cassandra.apache.org
Subject: Re: execute_prepared_cql_query and variable range filter parameter

Pierre: do you mind opening an 'improvement' ticket on
https://issues.apache.org/jira/browse/CASSANDRA for this? Wouldn't be crazy
to add support for it at some point.

--
Sylvain

On Tue, May 1, 2012 at 5:27 AM, paul cannon <pa...@datastax.com> wrote:
> No, there isn't right now.  But note that there shouldn't be a whole 
> lot of performance difference between
>
>     select * from Town where key in ('Paris', 'London');
>
> and
>
>     select * from Town where key = 'Paris';
>     select * from Town where key = 'London';
>
> ..other than round-trip times.  Or, I guess, if you're really worried 
> about preparation time, and your lists are limited to some small 
> maximum length X, you could prepare X different queries:
>
>     select * from Town where key in (?);
>     select * from Town where key in (?, ?);
>     select * from Town where key in (?, ?, ?);
>     etc.
>
> and then use the appropriate one each time, but I doubt that would be 
> a better solution overall.
>
> p
>
>
> On Mon, Apr 30, 2012 at 4:47 PM, Pierre Chalamet <pi...@chalamet.net>
> wrote:
>>
>> If I prepare “select * from Town where key in (?)”
>>
>> I will be able to bind ? to 'Paris' for example [è select * from Town 
>> where key in ('Paris')].
>>
>>
>>
>> If I want to query for 'Paris' and 'London', the query should be 
>> restated to “select * from Town where key in (?, ?)” [è select * from 
>> Town where key in ('Paris', 'London')].
>>
>> In that case, I must prepare the statement again, losing the benefit 
>> of prepare.
>>
>>
>>
>> Maybe there is another way to avoid preparing again ?
>>
>>
>>
>> Thanks,
>>
>> - Pierre
>>
>>
>>
>> From: paul cannon [mailto:paul@datastax.com]
>> Sent: lundi 30 avril 2012 23:36
>> To: user@cassandra.apache.org
>> Subject: Re: execute_prepared_cql_query and variable range filter 
>> parameter
>>
>>
>>
>> Hi Pierre-
>>
>>
>>
>> Yes, each ? can only represent one value at a time (although it can 
>> take on a different value for each actual execution of the prepared 
>> query). This is certainly normal for SQL binding libraries. Not sure 
>> why you feel that defeats statement preparation.
>>
>>
>>
>> p
>>
>>
>>
>> On Mon, Apr 30, 2012 at 3:45 PM, Pierre Chalamet 
>> <pi...@chalamet.net>
>> wrote:
>>
>> Hi all,
>>
>>
>>
>> Is there a support in Cassandra 1.1 for variable range filter 
>> parameter (sorry I can’t find a right name for that):
>>
>> select * from TestCF where key in (?)
>>
>>
>>
>> using execute_prepared_cql_query ?
>>
>>
>>
>> In the query above, it seems I can only bind one value to ‘?’.
>>
>> I mean, if several values are required for ‘?’ then I have to rewrite 
>> the query using several jokers.
>>
>>
>>
>> My problem is that this defeats statement preparation (using 
>> prepare_cql_query).
>>
>>
>>
>> Maybe there is a way to bind an array of values to a single command 
>> joker ?
>>
>>
>>
>> Thanks !
>>
>> - Pierre
>>
>>
>>
>>
>
>


Re: execute_prepared_cql_query and variable range filter parameter

Posted by Sylvain Lebresne <sy...@datastax.com>.
Pierre: do you mind opening an 'improvement' ticket on
https://issues.apache.org/jira/browse/CASSANDRA for this? Wouldn't be
crazy to add support for it at some point.

--
Sylvain

On Tue, May 1, 2012 at 5:27 AM, paul cannon <pa...@datastax.com> wrote:
> No, there isn't right now.  But note that there shouldn't be a whole lot of
> performance difference between
>
>     select * from Town where key in ('Paris', 'London');
>
> and
>
>     select * from Town where key = 'Paris';
>     select * from Town where key = 'London';
>
> ..other than round-trip times.  Or, I guess, if you're really worried about
> preparation time, and your lists are limited to some small maximum length X,
> you could prepare X different queries:
>
>     select * from Town where key in (?);
>     select * from Town where key in (?, ?);
>     select * from Town where key in (?, ?, ?);
>     etc.
>
> and then use the appropriate one each time, but I doubt that would be a
> better solution overall.
>
> p
>
>
> On Mon, Apr 30, 2012 at 4:47 PM, Pierre Chalamet <pi...@chalamet.net>
> wrote:
>>
>> If I prepare “select * from Town where key in (?)”
>>
>> I will be able to bind ? to 'Paris' for example [è select * from Town
>> where key in ('Paris')].
>>
>>
>>
>> If I want to query for 'Paris' and 'London', the query should be restated
>> to “select * from Town where key in (?, ?)” [è select * from Town where key
>> in ('Paris', 'London')].
>>
>> In that case, I must prepare the statement again, losing the benefit of
>> prepare.
>>
>>
>>
>> Maybe there is another way to avoid preparing again ?
>>
>>
>>
>> Thanks,
>>
>> - Pierre
>>
>>
>>
>> From: paul cannon [mailto:paul@datastax.com]
>> Sent: lundi 30 avril 2012 23:36
>> To: user@cassandra.apache.org
>> Subject: Re: execute_prepared_cql_query and variable range filter
>> parameter
>>
>>
>>
>> Hi Pierre-
>>
>>
>>
>> Yes, each ? can only represent one value at a time (although it can take
>> on a different value for each actual execution of the prepared query). This
>> is certainly normal for SQL binding libraries. Not sure why you feel that
>> defeats statement preparation.
>>
>>
>>
>> p
>>
>>
>>
>> On Mon, Apr 30, 2012 at 3:45 PM, Pierre Chalamet <pi...@chalamet.net>
>> wrote:
>>
>> Hi all,
>>
>>
>>
>> Is there a support in Cassandra 1.1 for variable range filter parameter
>> (sorry I can’t find a right name for that):
>>
>> select * from TestCF where key in (?)
>>
>>
>>
>> using execute_prepared_cql_query ?
>>
>>
>>
>> In the query above, it seems I can only bind one value to ‘?’.
>>
>> I mean, if several values are required for ‘?’ then I have to rewrite the
>> query using several jokers.
>>
>>
>>
>> My problem is that this defeats statement preparation (using
>> prepare_cql_query).
>>
>>
>>
>> Maybe there is a way to bind an array of values to a single command joker
>> ?
>>
>>
>>
>> Thanks !
>>
>> - Pierre
>>
>>
>>
>>
>
>

Re: execute_prepared_cql_query and variable range filter parameter

Posted by paul cannon <pa...@datastax.com>.
No, there isn't right now.  But note that there shouldn't be a whole lot of
performance difference between

    select * from Town where key in ('Paris', 'London');

and

    select * from Town where key = 'Paris';
    select * from Town where key = 'London';

..other than round-trip times.  Or, I guess, if you're really worried about
preparation time, and your lists are limited to some small maximum length
X, you could prepare X different queries:

    select * from Town where key in (?);
    select * from Town where key in (?, ?);
    select * from Town where key in (?, ?, ?);
    etc.

and then use the appropriate one each time, but I doubt that would be a
better solution overall.

p


On Mon, Apr 30, 2012 at 4:47 PM, Pierre Chalamet <pi...@chalamet.net>wrote:

> If I prepare “select * from Town where key in (?)”****
>
> I will be able to bind ? to 'Paris' for example [è select * from Town
> where key in ('Paris')].****
>
> ** **
>
> If I want to query for 'Paris' and 'London', the query should be restated
> to “select * from Town where key in (?, ?)” [è select * from Town where
> key in ('Paris', 'London')].****
>
> In that case, I must prepare the statement again, losing the benefit of
> prepare.****
>
> ** **
>
> Maybe there is another way to avoid preparing again ?****
>
> ** **
>
> Thanks,****
>
> - Pierre****
>
> ** **
>
> *From:* paul cannon [mailto:paul@datastax.com]
> *Sent:* lundi 30 avril 2012 23:36
> *To:* user@cassandra.apache.org
> *Subject:* Re: execute_prepared_cql_query and variable range filter
> parameter****
>
> ** **
>
> Hi Pierre-****
>
> ** **
>
> Yes, each ? can only represent one value at a time (although it can take
> on a different value for each actual execution of the prepared query). This
> is certainly normal for SQL binding libraries. Not sure why you feel that
> defeats statement preparation.****
>
> ** **
>
> p****
>
> ** **
>
> On Mon, Apr 30, 2012 at 3:45 PM, Pierre Chalamet <pi...@chalamet.net>
> wrote:****
>
> Hi all,****
>
>  ****
>
> Is there a support in Cassandra 1.1 for variable range filter parameter
> (sorry I can’t find a right name for that):****
>
> select * from TestCF where key in (?)****
>
>  ****
>
> using execute_prepared_cql_query ?****
>
>  ****
>
> In the query above, it seems I can only bind one value to ‘?’.****
>
> I mean, if several values are required for ‘?’ then I have to rewrite the
> query using several jokers.****
>
>  ****
>
> My problem is that this defeats statement preparation (using
> prepare_cql_query).****
>
>  ****
>
> Maybe there is a way to bind an array of values to a single command joker ?
> ****
>
>  ****
>
> Thanks !****
>
> - Pierre****
>
>  ****
>
> ** **
>

RE: execute_prepared_cql_query and variable range filter parameter

Posted by Pierre Chalamet <pi...@chalamet.net>.
If I prepare “select * from Town where key in (?)”

I will be able to bind ? to 'Paris' for example [è select * from Town where key in ('Paris')].

 

If I want to query for 'Paris' and 'London', the query should be restated to “select * from Town where key in (?, ?)” [è select * from Town where key in ('Paris', 'London')].

In that case, I must prepare the statement again, losing the benefit of prepare.

 

Maybe there is another way to avoid preparing again ?

 

Thanks,

- Pierre

 

From: paul cannon [mailto:paul@datastax.com] 
Sent: lundi 30 avril 2012 23:36
To: user@cassandra.apache.org
Subject: Re: execute_prepared_cql_query and variable range filter parameter

 

Hi Pierre-

 

Yes, each ? can only represent one value at a time (although it can take on a different value for each actual execution of the prepared query). This is certainly normal for SQL binding libraries. Not sure why you feel that defeats statement preparation.

 

p

 

On Mon, Apr 30, 2012 at 3:45 PM, Pierre Chalamet <pi...@chalamet.net> wrote:

Hi all,

 

Is there a support in Cassandra 1.1 for variable range filter parameter (sorry I can’t find a right name for that):

select * from TestCF where key in (?)

 

using execute_prepared_cql_query ?

 

In the query above, it seems I can only bind one value to ‘?’.

I mean, if several values are required for ‘?’ then I have to rewrite the query using several jokers.

 

My problem is that this defeats statement preparation (using prepare_cql_query).

 

Maybe there is a way to bind an array of values to a single command joker ?

 

Thanks !

- Pierre

 

 


Re: execute_prepared_cql_query and variable range filter parameter

Posted by paul cannon <pa...@datastax.com>.
Hi Pierre-

Yes, each ? can only represent one value at a time (although it can take on
a different value for each actual execution of the prepared query). This is
certainly normal for SQL binding libraries. Not sure why you feel that
defeats statement preparation.

p

On Mon, Apr 30, 2012 at 3:45 PM, Pierre Chalamet <pi...@chalamet.net>wrote:

> Hi all,****
>
> ** **
>
> Is there a support in Cassandra 1.1 for variable range filter parameter
> (sorry I can’t find a right name for that):****
>
> select * from TestCF where key in (?)****
>
> ** **
>
> using execute_prepared_cql_query ?****
>
> ** **
>
> In the query above, it seems I can only bind one value to ‘?’.****
>
> I mean, if several values are required for ‘?’ then I have to rewrite the
> query using several jokers.****
>
> ** **
>
> My problem is that this defeats statement preparation (using
> prepare_cql_query).****
>
> ** **
>
> Maybe there is a way to bind an array of values to a single command joker ?
> ****
>
> ** **
>
> Thanks !****
>
> - Pierre****
>
> ** **
>