Re: CQL performance inserting multiple cluster keys under same partition key

2014-08-27 Thread Sylvain Lebresne
On Tue, Aug 26, 2014 at 6:50 PM, Jaydeep Chovatia 
chovatia.jayd...@gmail.com wrote:

 Hi,

 I have question on inserting multiple cluster keys under same partition
 key.

 Ex:

 CREATE TABLE Employee (
   deptId int,
   empId int,
   name   varchar,
   address varchar,
   salary int,
   PRIMARY KEY(deptId, empId)
 );

 BEGIN *UNLOGGED *BATCH
   INSERT INTO Employee (deptId, empId, name, address, salary) VALUES (1,
 10, 'testNameA', 'testAddressA', 2);
   INSERT INTO Employee (deptId, empId, name, address, salary) VALUES (1,
 20, 'testNameB', 'testAddressB', 3);
 APPLY BATCH;

 Here we are inserting two cluster keys (10 and 20) under same partition
 key (1).
 Q1) Is this batch transaction atomic and isolated? If yes then is there
 any performance overhead with this syntax?


As long as the update are under the same partition key (and I insist, only
in that condition), logged (the one without the UNLOGGED keyword) and
unlogged batches behave *exactly* the same way. So yes, in that case the
batch is atomic and isolated (though on the isolation, you may want to be
aware that while technically isolated, the usual timestamp rules still
apply and so you might not get the behavior you think if 2 batches have the
same timestamp: see CASSANDRA-6123
https://issues.apache.org/jira/browse/CASSANDRA-6123). There is no also
no performance overhead (assuming you meant over logged batches).

Q2) Is this CQL syntax can be considered equivalent of Thrift
 batch_mutate?


It is equivalent, both (the CQL syntax and Thrift batch_mutate) resolve
to the same operation internally.

--
Sylvain


Re: CQL performance inserting multiple cluster keys under same partition key

2014-08-27 Thread Jaydeep Chovatia
This clarifies my doubt.
Thanks You Sylvain for your help.


On Tue, Aug 26, 2014 at 11:59 PM, Sylvain Lebresne sylv...@datastax.com
wrote:

 On Tue, Aug 26, 2014 at 6:50 PM, Jaydeep Chovatia 
 chovatia.jayd...@gmail.com wrote:

 Hi,

 I have question on inserting multiple cluster keys under same partition
 key.

 Ex:

 CREATE TABLE Employee (
   deptId int,
   empId int,
   name   varchar,
   address varchar,
   salary int,
   PRIMARY KEY(deptId, empId)
 );

 BEGIN *UNLOGGED *BATCH
   INSERT INTO Employee (deptId, empId, name, address, salary) VALUES (1,
 10, 'testNameA', 'testAddressA', 2);
   INSERT INTO Employee (deptId, empId, name, address, salary) VALUES (1,
 20, 'testNameB', 'testAddressB', 3);
 APPLY BATCH;

 Here we are inserting two cluster keys (10 and 20) under same partition
 key (1).
 Q1) Is this batch transaction atomic and isolated? If yes then is there
 any performance overhead with this syntax?


 As long as the update are under the same partition key (and I insist, only
 in that condition), logged (the one without the UNLOGGED keyword) and
 unlogged batches behave *exactly* the same way. So yes, in that case the
 batch is atomic and isolated (though on the isolation, you may want to be
 aware that while technically isolated, the usual timestamp rules still
 apply and so you might not get the behavior you think if 2 batches have the
 same timestamp: see CASSANDRA-6123
 https://issues.apache.org/jira/browse/CASSANDRA-6123). There is no also
 no performance overhead (assuming you meant over logged batches).

 Q2) Is this CQL syntax can be considered equivalent of Thrift
 batch_mutate?


 It is equivalent, both (the CQL syntax and Thrift batch_mutate) resolve
 to the same operation internally.

 --
 Sylvain



CQL performance inserting multiple cluster keys under same partition key

2014-08-26 Thread Jaydeep Chovatia
Hi,

I have question on inserting multiple cluster keys under same partition
key.

Ex:

CREATE TABLE Employee (
  deptId int,
  empId int,
  name   varchar,
  address varchar,
  salary int,
  PRIMARY KEY(deptId, empId)
);

BEGIN *UNLOGGED *BATCH
  INSERT INTO Employee (deptId, empId, name, address, salary) VALUES (1,
10, 'testNameA', 'testAddressA', 2);
  INSERT INTO Employee (deptId, empId, name, address, salary) VALUES (1,
20, 'testNameB', 'testAddressB', 3);
APPLY BATCH;

Here we are inserting two cluster keys (10 and 20) under same partition key
(1).
Q1) Is this batch transaction atomic and isolated? If yes then is there any
performance overhead with this syntax?
Q2) Is this CQL syntax can be considered equivalent of Thrift
batch_mutate?

-jaydeep


Re: CQL performance inserting multiple cluster keys under same partition key

2014-08-26 Thread Vivek Mishra
AFAIK, it is not. With CAS it should br
On 26/08/2014 10:21 pm, Jaydeep Chovatia chovatia.jayd...@gmail.com
wrote:

 Hi,

 I have question on inserting multiple cluster keys under same partition
 key.

 Ex:

 CREATE TABLE Employee (
   deptId int,
   empId int,
   name   varchar,
   address varchar,
   salary int,
   PRIMARY KEY(deptId, empId)
 );

 BEGIN *UNLOGGED *BATCH
   INSERT INTO Employee (deptId, empId, name, address, salary) VALUES (1,
 10, 'testNameA', 'testAddressA', 2);
   INSERT INTO Employee (deptId, empId, name, address, salary) VALUES (1,
 20, 'testNameB', 'testAddressB', 3);
 APPLY BATCH;

 Here we are inserting two cluster keys (10 and 20) under same partition
 key (1).
 Q1) Is this batch transaction atomic and isolated? If yes then is there
 any performance overhead with this syntax?
 Q2) Is this CQL syntax can be considered equivalent of Thrift
 batch_mutate?

 -jaydeep



Re: CQL performance inserting multiple cluster keys under same partition key

2014-08-26 Thread Jaydeep Chovatia
But if we look at thrift world batch_mutate then it used to perform all
mutations withing partition key atomically without using CAS i.e no extra
penalty.
Does this mean CQL degrades in performance as compared to thrift if we want
to do multiple updates to a partition key atomically?


On Tue, Aug 26, 2014 at 11:51 AM, Vivek Mishra mishra.v...@gmail.com
wrote:

 AFAIK, it is not. With CAS it should br
 On 26/08/2014 10:21 pm, Jaydeep Chovatia chovatia.jayd...@gmail.com
 wrote:

 Hi,

 I have question on inserting multiple cluster keys under same partition
 key.

 Ex:

 CREATE TABLE Employee (
   deptId int,
   empId int,
   name   varchar,
   address varchar,
   salary int,
   PRIMARY KEY(deptId, empId)
 );

 BEGIN *UNLOGGED *BATCH
   INSERT INTO Employee (deptId, empId, name, address, salary) VALUES (1,
 10, 'testNameA', 'testAddressA', 2);
   INSERT INTO Employee (deptId, empId, name, address, salary) VALUES (1,
 20, 'testNameB', 'testAddressB', 3);
 APPLY BATCH;

 Here we are inserting two cluster keys (10 and 20) under same partition
 key (1).
 Q1) Is this batch transaction atomic and isolated? If yes then is there
 any performance overhead with this syntax?
 Q2) Is this CQL syntax can be considered equivalent of Thrift
 batch_mutate?

 -jaydeep