Installation details
Scylla version (or git commit hash): 2.1-rc3 (2.1.rc3-0.20180207.b98d5b3)
I couldn't get the experimental secondary index support in 2.1 to work when the base table has a compound partition key. It works fine with a single column partition key but does not seem to work when more than one column is included in the partition key unless I am doing something dumb, as may very likely be the case.. Thanks.
CREATE KEYSPACE ks WITH REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor' : 1};
CREATE TABLE ks.users (userid uuid,name text,email text,country text,PRIMARY KEY ((userid,name)));
CREATE INDEX ON ks.users (email);
CREATE INDEX ON ks.users (country);
INSERT INTO ks.users (userid, name, email, country) VALUES (uuid(), 'Bondie Easseby', '[email protected]', 'France');
INSERT INTO ks.users (userid, name, email, country) VALUES (uuid(), 'Demetri Curror', '[email protected]', 'France');
INSERT INTO ks.users (userid, name, email, country) VALUES (uuid(), 'Langston Paulisch', '[email protected]', 'United States');
INSERT INTO ks.users (userid, name, email, country) VALUES (uuid(), 'Channa Devote', '[email protected]', 'Denmark');
SELECT * FROM ks.users WHERE email = '[email protected]';
userid | country | email | name
--------+---------+-------+------
(0 rows)
The MV is created properly and populated properly but it seems that it is not consulted with a multi-column partition key:
cqlsh> select * from ks.users_email_idx_index where email = '[email protected]';
email | userid | name
---------------------+--------------------------------------+----------------
[email protected] | 7062f5a4-7719-4d84-8b4e-70ce22cfa317 | Bondie Easseby
(1 rows)
cqlsh> select * from ks.users where userid = 7062f5a4-7719-4d84-8b4e-70ce22cfa317 and name = 'Bondie Easseby';
userid | name | country | email
--------------------------------------+----------------+---------+---------------------
7062f5a4-7719-4d84-8b4e-70ce22cfa317 | Bondie Easseby | France | [email protected]
(1 rows)
cqlsh> select * from ks.users where email = '[email protected]';
userid | name | country | email
--------+------+---------+-------
(0 rows)
@duarten ?
@penberg ?
Yup, we don't support that yet in the SI implementation. As mentioned in the blog post, 2.1 only supports indexing "regular columns" (no primary key columns, no static columns, no collection columns).
@penberg, how do the restrictions you mentionned apply to @veramine's example? email and country are both "regular columns", aren't they?
I think @vibi is, this is a different problem from what @penberg mentioned: @veramine only indexed regular columns. The problem is that the key is compound, so maybe the keys are either written incorrectly in the underlying MV, or searched wrong?
Most helpful comment
@penberg, how do the restrictions you mentionned apply to @veramine's example?
emailandcountryare both "regular columns", aren't they?