SlideShare a Scribd company logo
N1QLWORKSHOP:
INDEXING AND QUERYTUNING IN COUCHBASE 4.0
Keshav Murthy
Couchbase Engineering
keshav@couchbase.com
@N1QL @rkeshavmurthy
©2015 Couchbase Inc. 2
Agenda
 Indexing Overview
 View Index
 GSI Index
 Multi Index Scan
 Hands On N1QL
 QueryTuning with Hands on N1QL
 Index Selection Hints
 Key-ValueAccess
 Joins
 Hands On N1QL
Indexing Overview
©2015 Couchbase Inc. 4
Couchbase Server Cluster Service Deployment
4
STORAGE
Couchbase Server 1
SHARD
7
SHARD
9
SHARD
5
SHARDSHARDSHARD
Managed
Cache
Cluster
ManagerCluster
Manager
Managed Cache
Storage
Data
Servic
e
STORAGE
Couchbase Server 2
Managed
Cache
Cluster
ManagerCluster
Manager
Data
Servic
e
STORAGE
Couchbase Server 3
SHARD
7
SHARD
9
SHARD
5
SHARDSHARDSHARD
Managed
Cache
Cluster
ManagerCluster
Manager
Data
Servic
e
STORAGE
Couchbase Server 4
SHARD
7
SHARD
9
SHARD
5
SHARDSHARDSHARD
Managed
Cache
Cluster
ManagerCluster
Manager
Query
Servic
e
STORAGE
Couchbase Server 5
SHARD
7
SHARD
9
SHARD
5
SHARDSHARDSHARD
Managed
Cache
Cluster
ManagerCluster
Manager
Query
Servic
e
STORAGE
Couchbase Server 6
SHARD
7
SHARD
9
SHARD
5
SHARDSHARDSHARD
Managed
Cache
Cluster
ManagerCluster
Manager
Index
Servic
e
Managed Cache
Storage
Managed Cache
Storage Storage
STORAGE
Couchbase Server 6
SHARD
7
SHARD
9
SHARD
5
SHARDSHARDSHARD
Managed
Cache
Cluster
ManagerCluster
Manager
Index
Servic
e
Storage
Managed Cache Managed Cache
©2015 Couchbase Inc. 5
N1QL: Query Execution Flow
Clients
1. Submit the query over RESTAPI 8. Query result
2. Parse, Analyze, create Plan 7. Evaluate: Documents to results
3. Scan Request;
index filters
6. Fetch the documents
Index
Servic
e
Query
Service
Data
Servic
e
4. Get qualified doc keys
5. Fetch Request,
doc keys
SELECT firstname,
lastname,
state
FROM customer
WHERE customerid = "customer494";
{
"firstName": "Nicolette",
"lastName": "Wilderman",
"state": "IL“
}
©2015 Couchbase Inc. 6
N1QL: Query Execution Flow
Clients
1. Submit the query over RESTAPI 8. Query result
2. Parse, Analyze, create Plan 7. Evaluate: Documents to results
3. Scan Request;
index filters
6. Fetch the documents
Index
Servic
e
Query
Service
Data
Servic
e
4. Get qualified doc keys
5. Fetch Request,
doc keys
SELECT firstname,
lastname,
state
FROM customer
WHERE customerid = "customer494";
{
"firstName": "Nicolette",
"lastName": "Wilderman",
"state": "IL“
}
©2015 Couchbase Inc. 7
N1QL: Inside a Query Service
Client
FetchParse Plan Join Filter
Pre-Aggregate
Offset Limit ProjectSortAggregate
Index
Service
Data
Service
Scan
Query Service
©2015 Couchbase Inc. 8
Index Overview: Primary Index
 Primary Index
 CREATE PRIMARY INDEX PIX_CUST ON customer;
 Document key is unique for the bucket.
 Primary index is used when no other qualifying
index is available or when no predicate is given
in the query.
 PrimaryScan is equivalent of full table scan
"customer": {
"ccInfo": {
"cardExpiry": "2015-11-11",
"cardNumber”:"1212--1234",
"cardType": "americanexpress”
},
"customerId": "customer534",
"dateAdded": "2014-04-06",
"dateLastActive”:"2014-05-02”,
"emailAddress”:”iles@kertz.name",
"firstName": "Mckayla",
"lastName": "Brown",
"phoneNumber": "1-533-290-6403",
"postalCode": "92341",
"state": "VT",
"type": "customer"
}
Document key: “customer534”
©2015 Couchbase Inc. 9
Index Overview: Secondary Index
 Secondary Index can be created on any
combination of attribute names.
 CREATE INDEX idx_cust_cardnum
customer(ccInfo.cardNumber)
 CREATE INDEX idx_cust_postalCode
CUSTOMER(postalCode);
 Useful in speeding up the queries.
 Need to have matching indices with right key-
ordering
 (ccInfo.cardExpiry, postalCode)
 (type, state, lastName firstName)
"customer": {
"ccInfo": {
"cardExpiry": "2015-11-11",
"cardNumber”:"1212-232-1234",
"cardType": "americanexpress”
},
"customerId": "customer534",
"dateAdded": "2014-04-06",
"dateLastActive”:"2014-05-02”,
"emailAddress”:”iles@kertz.name",
"firstName": "Mckayla",
"lastName": "Brown",
"phoneNumber": "1-533-290-6403",
"postalCode": "92341",
"state": "VT",
"type": "customer"
}
Document key: “customer534”
©2015 Couchbase Inc. 10
Couchbase Indexes for N1QL
Fetch
Parse
Plan
Join
Filter
Offset
Limit
Project
Sort
Aggre
gate
Scan
Data Service
Global
Secondary
Index
View Indexes
Global
Secondary
Index
Global
Secondary
Index
IndexScan
IndexScan
Data
Access
Query
Service
Cluster Map
View Index
©2015 Couchbase Inc. 12
View Index
12
APPLICATION SERVER
VIEW
INDEXER
Query Set
 DCP based Replication: updates
queued for the indexer
 View Indexer: Executes incremental
map/reduce on a batch of updates
 Couchstore based Storage: updates
queued for storage
 ViewQuery Engine: REST Based
queries with filters, limit and more
executed with scatter-gather
 N1QLView Index: Created via
N1QL’sCREATE Index statement
 For Beta, View index is the default
CREATE PRIMARY INDEX px_customer ON customer USING VIEW;
CREATE INDEX idx_cust_postalCode customer(postalCode) USING VIEW ;
DROP INDEX customer.idx_cust_postalCode USING VIEW;
GSI Index
©2015 Couchbase Inc. 14
Data Service
Projector & Router
Global Secondary Index
Query Service
Bucket#1 Bucket#2
DCP Stream
Index Service
Supervisor
Index maintenance &
Scan coordinator
Index#2Index#1
Index#4Index#3
ForestDB
Storage Engine
B
u
c
k
e
t
#
2
B
u
c
k
e
t
#
1
©2015 Couchbase Inc. 15
GSI Index: Key details
 SupportedTypes
 String, Boolean, Numeric, Nil,Array, Sub-document
 Total length of the keys
 4 KB – actual length of the key indexed
 How the the length is calculated? Does it include the “key name”?
 Number of keys
 4096!
CREATE PRIMARY INDEX px_customer ON customer USING GSI;
CREATE INDEX idx_cust_postalCode customer(postalCode) USING GSI;
DROP INDEX customer.idx_cust_postalCode USING GSI;
©2015 Couchbase Inc. 16
Query Execution: Plan
Fetch
Parse
Plan
Join
Filter
Offset
Limit
Project
Sort
Aggre
gate
Scan
 Each query can be executed in several ways
 Create the query execution plan
 Access path for each keyspace reference
 Decide on the filters to push down
 Determine Join order and join method
 Create the execution tree
 For each keyspace reference:
 Look at the available indices
 Match the filters in the query with index keys
 Choose one or more indices for each keyspace
 Create index filters and post scan, post join filters
©2015 Couchbase Inc. 17
Query Execution: Plan
Fetch
Parse
Plan
Join
Filter
Offset
Limit
Project
Sort
Aggre
gate
Scan
{
"#operator": "IndexScan",
"index":
"CU_W_ID_D_ID_LAST",
"keyspace": "CUSTOMER",
…
"spans": [
{
"Range": {
"High": [
"49",
"16",
""Montana""
],
"Inclusion": 3,
"Low": [
"49",
"16",
EXPLAIN SELECT c_id,
c_first,
c_middle,
c_last,
c_balance
FROM CUSTOMER
WHERE c_w_id = 49
AND c_d_id = 16
AND c_last = ‘Montana’;
©2015 Couchbase Inc. 18
Query Execution: Plan
Fetch
Parse
Plan
Join
Filter
Offset
Limit
Project
Sort
Aggre
gate
Scan
"#operator": "Sequence",
"~children": [
{
"#operator": "PrimaryScan",
"index": "#primary",
"keyspace": "reviews",
"namespace": "default",
"using": "gsi"
},
{
"#operator": "Parallel",
"~child": {
"#operator": "Sequence",
"~children": [
{
"#operator": "Fetch",
"keyspace": "reviews",
"namespace": "default"
},
{
SELECT productid,
rating,
Count(productid)
FROM reviews
WHERE rating < 3
AND productid
BETWEEN "product300"
AND "product400"
GROUP BY productid,
rating;
©2015 Couchbase Inc. 19
Query Execution: Index Scan
 PrimaryScan
 Equivalent of full table scan in RDBMS
 Uses the primary index to scan from start to finish
 Index Scan
 Index selection is based on the filters and available
matching index
 Indices with expressions are matched with query
expressions
 N1QL can use one or more indices per table per
query
Data
Service
Global
Secondary
Index
View
Indexes
IndexScan
IndexScan
Data Fetch
Query
Service
Cluster
Map
Composite Indexes
©2015 Couchbase Inc. 21
Power Features: Composite Indexes
CREATE INDEX ix_last_postal ON PRODUCT(lastName, postalCode,
city);
SELECT * FROM product
WHERE
lastname= “Smith”
AND
postalCode = ‘58292’;
 Index scan using composite index:
– Needs first N keys to be used to choose the index
– Will multiple indexes on same set of columns to support filter push down
Power Features:
Index Intersection aka Multi Index Scan
©2015 Couchbase Inc. 23
Power Features: IntersectScan (Multi-Index Scan)
SELECT * FROM customer
WHERE lastName = ’Smith’ AND postalCode = ’94040’;
 IntersectScan using multiple indices:
– Multiple indices are scanned in parallel
– Provides more flexibility in using the indices for filters
– Requires less number of indexes defined on table.
• Can save on disk space and memory space as well.
Switch to Hands On N1QL
Page #55
Power Features:
Index Selection Hints
©2015 Couchbase Inc. 26
Query Execution: USE INDEX
CREATE INDEX ix_last_postal ON
PRODUCT(lastName, postalCode);
CREATE INDEX ix_postal_category ON
PRODUCT(postalCode,lastName);
SELECT * FROM product
WHERE
lastname= “Smith”
AND
postalCode = ‘58292’;
SELECT *
FROM product
USE INDEX(ix_last_postal using gsi)
WHERE
Category = “Smith”
AND
Name = ‘58292’;
Data
Service
Global
Secondary
Index
View
Indexes
IndexScan
IndexScan
Data Fetch
Query
Service
Cluster
Map
©2015 Couchbase Inc. 27
Query Execution: USE INDEX
CREATE INDEX ix_last ON
PRODUCT(lastName) USING GSI;
CREATE INDEX ix_postal ON
PRODUCT(postalCode) USING GSI;
SELECT *
FROM product
USE INDEX(ix_last USING GSI,
ix_postal USING GSI)
WHERE
Category = “Smith”
AND
Name = ‘58292’;
Data
Service
Global
Secondary
Index
View
Indexes
IndexScan
IndexScan
Data Fetch
Query
Service
Cluster
Map
N1QL Power Features: USE KEYS
©2015 Couchbase Inc. 29
Power Features: USE KEYS
Data Service
Global
Secondary
Index
View Indexes
Global
Secondary
Index
Global
Secondary
Index
KeyScan
IndexScan
IndexScan
Data Fetch
Query
Service
Cluster Map
©2015 Couchbase Inc. 30
Power Features: USE KEYS
SELECT customerId,
lastName,
firstName
FROM customer USE KEYS [‘customer494’];
 KeyScan: Directly use the Couchbase cluster map to get the
document
 You can give one or more values in the array
 From N1QL, get keys via: META(customer).id
Functional Indices
©2015 Couchbase Inc. 32
Functional Indices
"contacts": {
"age": 46,
"children": [
{
"age": 17,
"fname": "Aiden",
"gender": "m"
},
{
"age": 2,
"fname": "Bill",
"gender": "f"
}
],
"email": "dave@gmail.com",
"fname": "Dave",
"hobbies": [
"golf",
"surfing"
],
"lname": "Smith",
"relation": "friend",
"title": "Mr.",
"type": "contact"
CREATE INDEX idx_lname_lower ON
contacts(LOWER(lname)) using GSI;
SELECT count(*)
FROM contacts
WHERE lower(lname) = smith;
©2015 Couchbase Inc. 33
Functional Indices
"contacts": {
"age": 46,
"children": [
{
"age": 17,
"fname": "Aiden",
"gender": "m"
},
{
"age": 2,
"fname": "Bill",
"gender": "f"
}
],
"email": "dave@gmail.com",
"fname": "Dave",
"hobbies": [
"golf",
"surfing"
],
"lname": "Smith",
"relation": "friend",
"title": "Mr.",
"type": "contact"
 The value indexed is the result of the function or
expression.
 The query has to use the same expression in the
WHERE clause for the planner to consider using
the index.
 Use EXPLAIN to verify using the index.
Indexes on Arrays
©2015 Couchbase Inc. 35
Indexes on Arrays
cbq> select contacts.children from contacts limit 1;
{
"requestID": "e61a011f-2387-47d3-aee0-7bfd874ed2bf",
"signature": {
"children": "json"
},
"results": [
{
"children": [
{
"age": 17,
"fname": "Aiden",
"gender": "m"
},
{
"age": 2,
"fname": "Bill",
"gender": "f"
}
]
}
],
CREATE INDEX idx_ctx_children ON
contacts(children) USING GSI;
select * from system:indexes where name =
"idx_ctx_children";
"indexes": {
"datastore_id": "http://127.0.0.1:8091",
"id": "ea6023a0dd24bedc",
"index_key": [
"`children`"
],
"keyspace_id": "contacts",
"name": "idx_ctx_children",
"namespace_id": "default",
"state": "online",
"using": "gsi"
}
©2015 Couchbase Inc. 36
Indexes on Arrays
cbq> select contacts.children from contacts limit 1;
{
"requestID": "e61a011f-2387-47d3-aee0-7bfd874ed2bf",
"signature": {
"children": "json"
},
"results": [
{
"children": [
{
"age": 17,
"fname": "Aiden",
"gender": "m"
},
{
"age": 2,
"fname": "Bill",
"gender": "f"
}
]
}
],
select * from contacts where children[0] =
{"age":17, "fname":"Xena", "gender":"f"};
select *
from contacts c unnest c.children as anychild
where anychild = {"age":17, "fname":"Xena",
"gender":"f"};
©2015 Couchbase Inc. 37
Indexes on Arrays
cbq> select contacts.children from contacts limit 1;
{
"requestID": "e61a011f-2387-47d3-aee0-7bfd874ed2bf",
"signature": {
"children": "json"
},
"results": [
{
"children": [
{
"age": 17,
"fname": "Aiden",
"gender": "m"
},
{
"age": 2,
"fname": "Bill",
"gender": "f"
}
]
}
],
select * from contacts where children =
[
{ "age": 17, "fname": "Xena”, "gender": "f”},
{"age": 2,"fname": "Yuri”,"gender": "m”}
];
JOINS in N1QL
©2015 Couchbase Inc. 39
Query Execution: Join
"CUSTOMER": "customer": {
"ccInfo": {
"cardExpiry": "2015-11-11",
"cardNumber": "1212-1221-1121-1234",
"cardType": "americanexpress"
},
"customerId": "customer285",
"dateAdded": "2014-04-06T15:52:16Z",
"dateLastActive": "2014-05-06T15:52:16Z",
"emailAddress":
"jason_skiles@kertzmann.name",
"firstName": "Mckayla",
"lastName": "Brown",
"phoneNumber": "1-533-290-6403 x2729",
"postalCode": "92341",
"state": "VT",
"type": "customer"
}
Document key: “customer285” Document key: “purchase1492”
“purchases”:{
"customerId": "customer285",
"lineItems": [
{"count": 3,
"product": "product55”},
{"count": 4,
"product": "product169”},],
"purchaseId": "purchase7049",
"type": "purchase”
}
"purchases": {
"customerId": "customer285",
"lineItems": [
{ "count": 5,
"product”: "prod551" },
{ "count": 3,
"product": "product549" }, ],
"purchaseId": "purchase3648",
"purchasedAt": "2013-11-07T15:52:38Z",
"type": "purchase"
}
Document key: “purchase583”
©2015 Couchbase Inc. 40
Joins
SELECT c.customerid,
Count(*) totpurchases
FROM purchases p
INNER JOIN customer c
ON KEYS p.customerid
GROUP BY c.customerid
ORDER BY count(*) DESC limit 10;
Two keyspace joins
ON Clause for the join
Fetch
Parse
Plan
Join
Filter
Offset
Limit
Project
Sort
Aggre
gate
Scan
©2015 Couchbase Inc. 41
Joins
SELECT c_id,
c_first,
c_middle,
c_last,
(c_max - c_balance)
FROM CUSTOMER USE KEYS [‘1.10.1938’];
Fetch
Parse
Plan
Join
Filter
Offset
Limit
Project
Sort
Aggre
gate
Scan
SELECT c_id,
c_first,
c_middle,
c_last,
(c_max - c_balance)
FROM CUSTOMER USE KEYS
[to_string($1)|| “.” || to_string($2) ||
“.” || to_string($3)];
©2015 Couchbase Inc. 42
N1QL: Join
SELECT *
FROM ORDERS o INNER JOIN CUSTOMER c
ON KEYS (o.O_C_ID)
LEFT JOIN PREMIUM p
ON KEYS (c.C_PR_ID)
LEFT JOIN demographics d
ON KEYS (c.c_DEMO_ID)
Fetch
Parse
Plan
Join
Filter
Offset
Limit
Project
Sort
Aggre
gate
Scan
 Support INNER and LEFT OUTER joins
 Join order follows the order in the FROM clause.
 N1QL supports the nested loop joins now.
 Join is always from a key of one document(outer
table) to the document key of the second
document (inner table)
Switch to Hands On N1QL
Page #71
©2015 Couchbase Inc. 44
Summary
 Create indices with right set of keys
 Important to analyze your workload
 Primary Scan = FullTable Scan
 Indexes are maintained asynchronously.
 Set the right consistency level for your query
 Design your primary keys and document
references correctly.
 USE KEYS will get you the data fast
 EXPLAIN to understand query plan
 Take control when you must, USE INDEX hint
query.couchbase.com
@N1QL

More Related Content

What's hot

MongoDB .local Munich 2019: A Complete Methodology to Data Modeling for MongoDB
MongoDB .local Munich 2019: A Complete Methodology to Data Modeling for MongoDBMongoDB .local Munich 2019: A Complete Methodology to Data Modeling for MongoDB
MongoDB .local Munich 2019: A Complete Methodology to Data Modeling for MongoDB
MongoDB
 
Doing Joins in MongoDB: Best Practices for Using $lookup
Doing Joins in MongoDB: Best Practices for Using $lookupDoing Joins in MongoDB: Best Practices for Using $lookup
Doing Joins in MongoDB: Best Practices for Using $lookup
MongoDB
 
MongoDB .local Chicago 2019: Still Haven't Found What You Are Looking For? Us...
MongoDB .local Chicago 2019: Still Haven't Found What You Are Looking For? Us...MongoDB .local Chicago 2019: Still Haven't Found What You Are Looking For? Us...
MongoDB .local Chicago 2019: Still Haven't Found What You Are Looking For? Us...
MongoDB
 
MongoDB Atlas Workshop - Singapore
MongoDB Atlas Workshop - SingaporeMongoDB Atlas Workshop - Singapore
MongoDB Atlas Workshop - Singapore
Ashnikbiz
 
MongoDB .local Munich 2019: Managing a Heterogeneous Stack with MongoDB & SQL
MongoDB .local Munich 2019: Managing a Heterogeneous Stack with MongoDB & SQLMongoDB .local Munich 2019: Managing a Heterogeneous Stack with MongoDB & SQL
MongoDB .local Munich 2019: Managing a Heterogeneous Stack with MongoDB & SQL
MongoDB
 
Jumpstart: Introduction to MongoDB
Jumpstart: Introduction to MongoDBJumpstart: Introduction to MongoDB
Jumpstart: Introduction to MongoDB
MongoDB
 
MongoDB and Hadoop: Driving Business Insights
MongoDB and Hadoop: Driving Business InsightsMongoDB and Hadoop: Driving Business Insights
MongoDB and Hadoop: Driving Business Insights
MongoDB
 
IOOF IT System Modernisation
IOOF IT System ModernisationIOOF IT System Modernisation
IOOF IT System Modernisation
MongoDB
 
MongoDB Europe 2016 - Who’s Helping Themselves To Your Data? Demystifying Mon...
MongoDB Europe 2016 - Who’s Helping Themselves To Your Data? Demystifying Mon...MongoDB Europe 2016 - Who’s Helping Themselves To Your Data? Demystifying Mon...
MongoDB Europe 2016 - Who’s Helping Themselves To Your Data? Demystifying Mon...
MongoDB
 
MongoDB .local Munich 2019: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local Munich 2019: MongoDB Atlas Data Lake Technical Deep DiveMongoDB .local Munich 2019: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local Munich 2019: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB
 
Tutorial: Building Your First App with MongoDB Stitch
Tutorial: Building Your First App with MongoDB StitchTutorial: Building Your First App with MongoDB Stitch
Tutorial: Building Your First App with MongoDB Stitch
MongoDB
 
Querying NoSQL with SQL - MIGANG - July 2017
Querying NoSQL with SQL - MIGANG - July 2017Querying NoSQL with SQL - MIGANG - July 2017
Querying NoSQL with SQL - MIGANG - July 2017
Matthew Groves
 
MongoDB Schema Design Tips & Tricks
MongoDB Schema Design Tips & TricksMongoDB Schema Design Tips & Tricks
MongoDB Schema Design Tips & Tricks
Juan Antonio Roy Couto
 
MongoDB - General Purpose Database
MongoDB - General Purpose DatabaseMongoDB - General Purpose Database
MongoDB - General Purpose Database
Ashnikbiz
 
Indexing Strategies to Help You Scale
Indexing Strategies to Help You ScaleIndexing Strategies to Help You Scale
Indexing Strategies to Help You Scale
MongoDB
 
MongoDB Europe 2016 - MongoDB 3.4 preview and introduction to MongoDB Atlas
MongoDB Europe 2016 - MongoDB 3.4 preview and introduction to MongoDB AtlasMongoDB Europe 2016 - MongoDB 3.4 preview and introduction to MongoDB Atlas
MongoDB Europe 2016 - MongoDB 3.4 preview and introduction to MongoDB Atlas
MongoDB
 
MongoDB + Spring
MongoDB + SpringMongoDB + Spring
MongoDB + Spring
Norberto Leite
 
MongoDB Launchpad 2016: What’s New in the 3.4 Server
MongoDB Launchpad 2016: What’s New in the 3.4 ServerMongoDB Launchpad 2016: What’s New in the 3.4 Server
MongoDB Launchpad 2016: What’s New in the 3.4 Server
MongoDB
 
Advanced Schema Design Patterns
Advanced Schema Design PatternsAdvanced Schema Design Patterns
Advanced Schema Design Patterns
MongoDB
 
Jumpstart: Introduction to Schema Design
Jumpstart: Introduction to Schema DesignJumpstart: Introduction to Schema Design
Jumpstart: Introduction to Schema Design
MongoDB
 

What's hot (20)

MongoDB .local Munich 2019: A Complete Methodology to Data Modeling for MongoDB
MongoDB .local Munich 2019: A Complete Methodology to Data Modeling for MongoDBMongoDB .local Munich 2019: A Complete Methodology to Data Modeling for MongoDB
MongoDB .local Munich 2019: A Complete Methodology to Data Modeling for MongoDB
 
Doing Joins in MongoDB: Best Practices for Using $lookup
Doing Joins in MongoDB: Best Practices for Using $lookupDoing Joins in MongoDB: Best Practices for Using $lookup
Doing Joins in MongoDB: Best Practices for Using $lookup
 
MongoDB .local Chicago 2019: Still Haven't Found What You Are Looking For? Us...
MongoDB .local Chicago 2019: Still Haven't Found What You Are Looking For? Us...MongoDB .local Chicago 2019: Still Haven't Found What You Are Looking For? Us...
MongoDB .local Chicago 2019: Still Haven't Found What You Are Looking For? Us...
 
MongoDB Atlas Workshop - Singapore
MongoDB Atlas Workshop - SingaporeMongoDB Atlas Workshop - Singapore
MongoDB Atlas Workshop - Singapore
 
MongoDB .local Munich 2019: Managing a Heterogeneous Stack with MongoDB & SQL
MongoDB .local Munich 2019: Managing a Heterogeneous Stack with MongoDB & SQLMongoDB .local Munich 2019: Managing a Heterogeneous Stack with MongoDB & SQL
MongoDB .local Munich 2019: Managing a Heterogeneous Stack with MongoDB & SQL
 
Jumpstart: Introduction to MongoDB
Jumpstart: Introduction to MongoDBJumpstart: Introduction to MongoDB
Jumpstart: Introduction to MongoDB
 
MongoDB and Hadoop: Driving Business Insights
MongoDB and Hadoop: Driving Business InsightsMongoDB and Hadoop: Driving Business Insights
MongoDB and Hadoop: Driving Business Insights
 
IOOF IT System Modernisation
IOOF IT System ModernisationIOOF IT System Modernisation
IOOF IT System Modernisation
 
MongoDB Europe 2016 - Who’s Helping Themselves To Your Data? Demystifying Mon...
MongoDB Europe 2016 - Who’s Helping Themselves To Your Data? Demystifying Mon...MongoDB Europe 2016 - Who’s Helping Themselves To Your Data? Demystifying Mon...
MongoDB Europe 2016 - Who’s Helping Themselves To Your Data? Demystifying Mon...
 
MongoDB .local Munich 2019: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local Munich 2019: MongoDB Atlas Data Lake Technical Deep DiveMongoDB .local Munich 2019: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local Munich 2019: MongoDB Atlas Data Lake Technical Deep Dive
 
Tutorial: Building Your First App with MongoDB Stitch
Tutorial: Building Your First App with MongoDB StitchTutorial: Building Your First App with MongoDB Stitch
Tutorial: Building Your First App with MongoDB Stitch
 
Querying NoSQL with SQL - MIGANG - July 2017
Querying NoSQL with SQL - MIGANG - July 2017Querying NoSQL with SQL - MIGANG - July 2017
Querying NoSQL with SQL - MIGANG - July 2017
 
MongoDB Schema Design Tips & Tricks
MongoDB Schema Design Tips & TricksMongoDB Schema Design Tips & Tricks
MongoDB Schema Design Tips & Tricks
 
MongoDB - General Purpose Database
MongoDB - General Purpose DatabaseMongoDB - General Purpose Database
MongoDB - General Purpose Database
 
Indexing Strategies to Help You Scale
Indexing Strategies to Help You ScaleIndexing Strategies to Help You Scale
Indexing Strategies to Help You Scale
 
MongoDB Europe 2016 - MongoDB 3.4 preview and introduction to MongoDB Atlas
MongoDB Europe 2016 - MongoDB 3.4 preview and introduction to MongoDB AtlasMongoDB Europe 2016 - MongoDB 3.4 preview and introduction to MongoDB Atlas
MongoDB Europe 2016 - MongoDB 3.4 preview and introduction to MongoDB Atlas
 
MongoDB + Spring
MongoDB + SpringMongoDB + Spring
MongoDB + Spring
 
MongoDB Launchpad 2016: What’s New in the 3.4 Server
MongoDB Launchpad 2016: What’s New in the 3.4 ServerMongoDB Launchpad 2016: What’s New in the 3.4 Server
MongoDB Launchpad 2016: What’s New in the 3.4 Server
 
Advanced Schema Design Patterns
Advanced Schema Design PatternsAdvanced Schema Design Patterns
Advanced Schema Design Patterns
 
Jumpstart: Introduction to Schema Design
Jumpstart: Introduction to Schema DesignJumpstart: Introduction to Schema Design
Jumpstart: Introduction to Schema Design
 

Viewers also liked

Query in Couchbase. N1QL: SQL for JSON
Query in Couchbase.  N1QL: SQL for JSONQuery in Couchbase.  N1QL: SQL for JSON
Query in Couchbase. N1QL: SQL for JSON
Keshav Murthy
 
nitro
nitronitro
Drilling on JSON
Drilling on JSONDrilling on JSON
Drilling on JSON
Keshav Murthy
 
Introduction to NoSQL and Couchbase
Introduction to NoSQL and CouchbaseIntroduction to NoSQL and Couchbase
Introduction to NoSQL and Couchbase
Cecile Le Pape
 
Utilizing Arrays: Modeling, Querying and Indexing
Utilizing Arrays: Modeling, Querying and IndexingUtilizing Arrays: Modeling, Querying and Indexing
Utilizing Arrays: Modeling, Querying and Indexing
Keshav Murthy
 
Couchbase Day
Couchbase DayCouchbase Day
Couchbase Day
Idan Tohami
 
Deep dive into N1QL: SQL for JSON: Internals and power features.
Deep dive into N1QL: SQL for JSON: Internals and power features.Deep dive into N1QL: SQL for JSON: Internals and power features.
Deep dive into N1QL: SQL for JSON: Internals and power features.
Keshav Murthy
 
Couchbase @ Big Data France 2016
Couchbase @ Big Data France 2016Couchbase @ Big Data France 2016
Couchbase @ Big Data France 2016
Cecile Le Pape
 
SDEC2011 Using Couchbase for social game scaling and speed
SDEC2011 Using Couchbase for social game scaling and speedSDEC2011 Using Couchbase for social game scaling and speed
SDEC2011 Using Couchbase for social game scaling and speed
Korea Sdec
 
Accelerating analytics on the Sensor and IoT Data.
Accelerating analytics on the Sensor and IoT Data. Accelerating analytics on the Sensor and IoT Data.
Accelerating analytics on the Sensor and IoT Data.
Keshav Murthy
 

Viewers also liked (10)

Query in Couchbase. N1QL: SQL for JSON
Query in Couchbase.  N1QL: SQL for JSONQuery in Couchbase.  N1QL: SQL for JSON
Query in Couchbase. N1QL: SQL for JSON
 
nitro
nitronitro
nitro
 
Drilling on JSON
Drilling on JSONDrilling on JSON
Drilling on JSON
 
Introduction to NoSQL and Couchbase
Introduction to NoSQL and CouchbaseIntroduction to NoSQL and Couchbase
Introduction to NoSQL and Couchbase
 
Utilizing Arrays: Modeling, Querying and Indexing
Utilizing Arrays: Modeling, Querying and IndexingUtilizing Arrays: Modeling, Querying and Indexing
Utilizing Arrays: Modeling, Querying and Indexing
 
Couchbase Day
Couchbase DayCouchbase Day
Couchbase Day
 
Deep dive into N1QL: SQL for JSON: Internals and power features.
Deep dive into N1QL: SQL for JSON: Internals and power features.Deep dive into N1QL: SQL for JSON: Internals and power features.
Deep dive into N1QL: SQL for JSON: Internals and power features.
 
Couchbase @ Big Data France 2016
Couchbase @ Big Data France 2016Couchbase @ Big Data France 2016
Couchbase @ Big Data France 2016
 
SDEC2011 Using Couchbase for social game scaling and speed
SDEC2011 Using Couchbase for social game scaling and speedSDEC2011 Using Couchbase for social game scaling and speed
SDEC2011 Using Couchbase for social game scaling and speed
 
Accelerating analytics on the Sensor and IoT Data.
Accelerating analytics on the Sensor and IoT Data. Accelerating analytics on the Sensor and IoT Data.
Accelerating analytics on the Sensor and IoT Data.
 

Similar to N1QL workshop: Indexing & Query turning.

MongoDB Stitch Introduction
MongoDB Stitch IntroductionMongoDB Stitch Introduction
MongoDB Stitch Introduction
MongoDB
 
ELK - What's new and showcases
ELK - What's new and showcasesELK - What's new and showcases
ELK - What's new and showcases
Andrii Gakhov
 
Couchbase N1QL: Index Advisor
Couchbase N1QL: Index AdvisorCouchbase N1QL: Index Advisor
Couchbase N1QL: Index Advisor
Keshav Murthy
 
Presentation
PresentationPresentation
Presentation
Dimitris Stripelis
 
WSO2 Analytics Platform - The one stop shop for all your data needs
WSO2 Analytics Platform - The one stop shop for all your data needsWSO2 Analytics Platform - The one stop shop for all your data needs
WSO2 Analytics Platform - The one stop shop for all your data needs
Sriskandarajah Suhothayan
 
NoSQL Data Modeling using Couchbase
NoSQL Data Modeling using CouchbaseNoSQL Data Modeling using Couchbase
NoSQL Data Modeling using Couchbase
Brant Burnett
 
New Approaches for Fraud Detection on Apache Kafka and KSQL
New Approaches for Fraud Detection on Apache Kafka and KSQLNew Approaches for Fraud Detection on Apache Kafka and KSQL
New Approaches for Fraud Detection on Apache Kafka and KSQL
confluent
 
Simplifying & accelerating application development with MongoDB's intelligent...
Simplifying & accelerating application development with MongoDB's intelligent...Simplifying & accelerating application development with MongoDB's intelligent...
Simplifying & accelerating application development with MongoDB's intelligent...
Maxime Beugnet
 
MongodB Internals
MongodB InternalsMongodB Internals
MongodB Internals
Norberto Leite
 
Stratio: Geospatial and bitemporal search in Cassandra with pluggable Lucene ...
Stratio: Geospatial and bitemporal search in Cassandra with pluggable Lucene ...Stratio: Geospatial and bitemporal search in Cassandra with pluggable Lucene ...
Stratio: Geospatial and bitemporal search in Cassandra with pluggable Lucene ...
DataStax Academy
 
Geospatial and bitemporal search in cassandra with pluggable lucene index
Geospatial and bitemporal search in cassandra with pluggable lucene indexGeospatial and bitemporal search in cassandra with pluggable lucene index
Geospatial and bitemporal search in cassandra with pluggable lucene index
Andrés de la Peña
 
Microsoft Azure Big Data Analytics
Microsoft Azure Big Data AnalyticsMicrosoft Azure Big Data Analytics
Microsoft Azure Big Data Analytics
Mark Kromer
 
Webinar: The Anatomy of the Cloudant Data Layer
Webinar: The Anatomy of the Cloudant Data LayerWebinar: The Anatomy of the Cloudant Data Layer
Webinar: The Anatomy of the Cloudant Data Layer
IBM Cloud Data Services
 
Time series Analytics - a deep dive into ADX Azure Data Explorer @Data Saturd...
Time series Analytics - a deep dive into ADX Azure Data Explorer @Data Saturd...Time series Analytics - a deep dive into ADX Azure Data Explorer @Data Saturd...
Time series Analytics - a deep dive into ADX Azure Data Explorer @Data Saturd...
Riccardo Zamana
 
DEVNET-1166 Open SDN Controller APIs
DEVNET-1166	Open SDN Controller APIsDEVNET-1166	Open SDN Controller APIs
DEVNET-1166 Open SDN Controller APIs
Cisco DevNet
 
MongoDB Stich Overview
MongoDB Stich OverviewMongoDB Stich Overview
MongoDB Stich Overview
MongoDB
 
Global Secondary Indexes in Couchbase Server 4.0 - JUNE 2015
Global Secondary Indexes in Couchbase Server 4.0 - JUNE 2015Global Secondary Indexes in Couchbase Server 4.0 - JUNE 2015
Global Secondary Indexes in Couchbase Server 4.0 - JUNE 2015
Cihan Biyikoglu
 
Slides: Moving from a Relational Model to NoSQL
Slides: Moving from a Relational Model to NoSQLSlides: Moving from a Relational Model to NoSQL
Slides: Moving from a Relational Model to NoSQL
DATAVERSITY
 
SQL for JSON: Rich, Declarative Querying for NoSQL Databases and Applications 
SQL for JSON: Rich, Declarative Querying for NoSQL Databases and Applications SQL for JSON: Rich, Declarative Querying for NoSQL Databases and Applications 
SQL for JSON: Rich, Declarative Querying for NoSQL Databases and Applications 
Keshav Murthy
 
All Streams Ahead! ksqlDB Workshop ANZ
All Streams Ahead! ksqlDB Workshop ANZAll Streams Ahead! ksqlDB Workshop ANZ
All Streams Ahead! ksqlDB Workshop ANZ
confluent
 

Similar to N1QL workshop: Indexing & Query turning. (20)

MongoDB Stitch Introduction
MongoDB Stitch IntroductionMongoDB Stitch Introduction
MongoDB Stitch Introduction
 
ELK - What's new and showcases
ELK - What's new and showcasesELK - What's new and showcases
ELK - What's new and showcases
 
Couchbase N1QL: Index Advisor
Couchbase N1QL: Index AdvisorCouchbase N1QL: Index Advisor
Couchbase N1QL: Index Advisor
 
Presentation
PresentationPresentation
Presentation
 
WSO2 Analytics Platform - The one stop shop for all your data needs
WSO2 Analytics Platform - The one stop shop for all your data needsWSO2 Analytics Platform - The one stop shop for all your data needs
WSO2 Analytics Platform - The one stop shop for all your data needs
 
NoSQL Data Modeling using Couchbase
NoSQL Data Modeling using CouchbaseNoSQL Data Modeling using Couchbase
NoSQL Data Modeling using Couchbase
 
New Approaches for Fraud Detection on Apache Kafka and KSQL
New Approaches for Fraud Detection on Apache Kafka and KSQLNew Approaches for Fraud Detection on Apache Kafka and KSQL
New Approaches for Fraud Detection on Apache Kafka and KSQL
 
Simplifying & accelerating application development with MongoDB's intelligent...
Simplifying & accelerating application development with MongoDB's intelligent...Simplifying & accelerating application development with MongoDB's intelligent...
Simplifying & accelerating application development with MongoDB's intelligent...
 
MongodB Internals
MongodB InternalsMongodB Internals
MongodB Internals
 
Stratio: Geospatial and bitemporal search in Cassandra with pluggable Lucene ...
Stratio: Geospatial and bitemporal search in Cassandra with pluggable Lucene ...Stratio: Geospatial and bitemporal search in Cassandra with pluggable Lucene ...
Stratio: Geospatial and bitemporal search in Cassandra with pluggable Lucene ...
 
Geospatial and bitemporal search in cassandra with pluggable lucene index
Geospatial and bitemporal search in cassandra with pluggable lucene indexGeospatial and bitemporal search in cassandra with pluggable lucene index
Geospatial and bitemporal search in cassandra with pluggable lucene index
 
Microsoft Azure Big Data Analytics
Microsoft Azure Big Data AnalyticsMicrosoft Azure Big Data Analytics
Microsoft Azure Big Data Analytics
 
Webinar: The Anatomy of the Cloudant Data Layer
Webinar: The Anatomy of the Cloudant Data LayerWebinar: The Anatomy of the Cloudant Data Layer
Webinar: The Anatomy of the Cloudant Data Layer
 
Time series Analytics - a deep dive into ADX Azure Data Explorer @Data Saturd...
Time series Analytics - a deep dive into ADX Azure Data Explorer @Data Saturd...Time series Analytics - a deep dive into ADX Azure Data Explorer @Data Saturd...
Time series Analytics - a deep dive into ADX Azure Data Explorer @Data Saturd...
 
DEVNET-1166 Open SDN Controller APIs
DEVNET-1166	Open SDN Controller APIsDEVNET-1166	Open SDN Controller APIs
DEVNET-1166 Open SDN Controller APIs
 
MongoDB Stich Overview
MongoDB Stich OverviewMongoDB Stich Overview
MongoDB Stich Overview
 
Global Secondary Indexes in Couchbase Server 4.0 - JUNE 2015
Global Secondary Indexes in Couchbase Server 4.0 - JUNE 2015Global Secondary Indexes in Couchbase Server 4.0 - JUNE 2015
Global Secondary Indexes in Couchbase Server 4.0 - JUNE 2015
 
Slides: Moving from a Relational Model to NoSQL
Slides: Moving from a Relational Model to NoSQLSlides: Moving from a Relational Model to NoSQL
Slides: Moving from a Relational Model to NoSQL
 
SQL for JSON: Rich, Declarative Querying for NoSQL Databases and Applications 
SQL for JSON: Rich, Declarative Querying for NoSQL Databases and Applications SQL for JSON: Rich, Declarative Querying for NoSQL Databases and Applications 
SQL for JSON: Rich, Declarative Querying for NoSQL Databases and Applications 
 
All Streams Ahead! ksqlDB Workshop ANZ
All Streams Ahead! ksqlDB Workshop ANZAll Streams Ahead! ksqlDB Workshop ANZ
All Streams Ahead! ksqlDB Workshop ANZ
 

More from Keshav Murthy

N1QL New Features in couchbase 7.0
N1QL New Features in couchbase 7.0N1QL New Features in couchbase 7.0
N1QL New Features in couchbase 7.0
Keshav Murthy
 
Couchbase Tutorial: Big data Open Source Systems: VLDB2018
Couchbase Tutorial: Big data Open Source Systems: VLDB2018Couchbase Tutorial: Big data Open Source Systems: VLDB2018
Couchbase Tutorial: Big data Open Source Systems: VLDB2018
Keshav Murthy
 
N1QL+GSI: Language and Performance Improvements in Couchbase 5.0 and 5.5
N1QL+GSI: Language and Performance Improvements in Couchbase 5.0 and 5.5N1QL+GSI: Language and Performance Improvements in Couchbase 5.0 and 5.5
N1QL+GSI: Language and Performance Improvements in Couchbase 5.0 and 5.5
Keshav Murthy
 
XLDB Lightning Talk: Databases for an Engaged World: Requirements and Design...
XLDB Lightning Talk: Databases for an Engaged World: Requirements and Design...XLDB Lightning Talk: Databases for an Engaged World: Requirements and Design...
XLDB Lightning Talk: Databases for an Engaged World: Requirements and Design...
Keshav Murthy
 
Couchbase 5.5: N1QL and Indexing features
Couchbase 5.5: N1QL and Indexing featuresCouchbase 5.5: N1QL and Indexing features
Couchbase 5.5: N1QL and Indexing features
Keshav Murthy
 
N1QL: Query Optimizer Improvements in Couchbase 5.0. By, Sitaram Vemulapalli
N1QL: Query Optimizer Improvements in Couchbase 5.0. By, Sitaram VemulapalliN1QL: Query Optimizer Improvements in Couchbase 5.0. By, Sitaram Vemulapalli
N1QL: Query Optimizer Improvements in Couchbase 5.0. By, Sitaram Vemulapalli
Keshav Murthy
 
Couchbase N1QL: Language & Architecture Overview.
Couchbase N1QL: Language & Architecture Overview.Couchbase N1QL: Language & Architecture Overview.
Couchbase N1QL: Language & Architecture Overview.
Keshav Murthy
 
Couchbase Query Workbench Enhancements By Eben Haber
Couchbase Query Workbench Enhancements  By Eben Haber Couchbase Query Workbench Enhancements  By Eben Haber
Couchbase Query Workbench Enhancements By Eben Haber
Keshav Murthy
 
Mindmap: Oracle to Couchbase for developers
Mindmap: Oracle to Couchbase for developersMindmap: Oracle to Couchbase for developers
Mindmap: Oracle to Couchbase for developers
Keshav Murthy
 
N1QL: What's new in Couchbase 5.0
N1QL: What's new in Couchbase 5.0N1QL: What's new in Couchbase 5.0
N1QL: What's new in Couchbase 5.0
Keshav Murthy
 
Extended JOIN in Couchbase Server 4.5
Extended JOIN in Couchbase Server 4.5Extended JOIN in Couchbase Server 4.5
Extended JOIN in Couchbase Server 4.5
Keshav Murthy
 
Introducing N1QL: New SQL Based Query Language for JSON
Introducing N1QL: New SQL Based Query Language for JSONIntroducing N1QL: New SQL Based Query Language for JSON
Introducing N1QL: New SQL Based Query Language for JSON
Keshav Murthy
 
Enterprise Architect's view of Couchbase 4.0 with N1QL
Enterprise Architect's view of Couchbase 4.0 with N1QLEnterprise Architect's view of Couchbase 4.0 with N1QL
Enterprise Architect's view of Couchbase 4.0 with N1QL
Keshav Murthy
 
You know what iMEAN? Using MEAN stack for application dev on Informix
You know what iMEAN? Using MEAN stack for application dev on InformixYou know what iMEAN? Using MEAN stack for application dev on Informix
You know what iMEAN? Using MEAN stack for application dev on Informix
Keshav Murthy
 
Informix SQL & NoSQL: Putting it all together
Informix SQL & NoSQL: Putting it all togetherInformix SQL & NoSQL: Putting it all together
Informix SQL & NoSQL: Putting it all together
Keshav Murthy
 
Informix SQL & NoSQL -- for Chat with the labs on 4/22
Informix SQL & NoSQL -- for Chat with the labs on 4/22Informix SQL & NoSQL -- for Chat with the labs on 4/22
Informix SQL & NoSQL -- for Chat with the labs on 4/22
Keshav Murthy
 
NoSQL Deepdive - with Informix NoSQL. IOD 2013
NoSQL Deepdive - with Informix NoSQL. IOD 2013NoSQL Deepdive - with Informix NoSQL. IOD 2013
NoSQL Deepdive - with Informix NoSQL. IOD 2013
Keshav Murthy
 
Informix NoSQL & Hybrid SQL detailed deep dive
Informix NoSQL & Hybrid SQL detailed deep diveInformix NoSQL & Hybrid SQL detailed deep dive
Informix NoSQL & Hybrid SQL detailed deep dive
Keshav Murthy
 
Table for two? Hybrid approach to developing combined SQL, NoSQL applications...
Table for two? Hybrid approach to developing combined SQL, NoSQL applications...Table for two? Hybrid approach to developing combined SQL, NoSQL applications...
Table for two? Hybrid approach to developing combined SQL, NoSQL applications...
Keshav Murthy
 

More from Keshav Murthy (19)

N1QL New Features in couchbase 7.0
N1QL New Features in couchbase 7.0N1QL New Features in couchbase 7.0
N1QL New Features in couchbase 7.0
 
Couchbase Tutorial: Big data Open Source Systems: VLDB2018
Couchbase Tutorial: Big data Open Source Systems: VLDB2018Couchbase Tutorial: Big data Open Source Systems: VLDB2018
Couchbase Tutorial: Big data Open Source Systems: VLDB2018
 
N1QL+GSI: Language and Performance Improvements in Couchbase 5.0 and 5.5
N1QL+GSI: Language and Performance Improvements in Couchbase 5.0 and 5.5N1QL+GSI: Language and Performance Improvements in Couchbase 5.0 and 5.5
N1QL+GSI: Language and Performance Improvements in Couchbase 5.0 and 5.5
 
XLDB Lightning Talk: Databases for an Engaged World: Requirements and Design...
XLDB Lightning Talk: Databases for an Engaged World: Requirements and Design...XLDB Lightning Talk: Databases for an Engaged World: Requirements and Design...
XLDB Lightning Talk: Databases for an Engaged World: Requirements and Design...
 
Couchbase 5.5: N1QL and Indexing features
Couchbase 5.5: N1QL and Indexing featuresCouchbase 5.5: N1QL and Indexing features
Couchbase 5.5: N1QL and Indexing features
 
N1QL: Query Optimizer Improvements in Couchbase 5.0. By, Sitaram Vemulapalli
N1QL: Query Optimizer Improvements in Couchbase 5.0. By, Sitaram VemulapalliN1QL: Query Optimizer Improvements in Couchbase 5.0. By, Sitaram Vemulapalli
N1QL: Query Optimizer Improvements in Couchbase 5.0. By, Sitaram Vemulapalli
 
Couchbase N1QL: Language & Architecture Overview.
Couchbase N1QL: Language & Architecture Overview.Couchbase N1QL: Language & Architecture Overview.
Couchbase N1QL: Language & Architecture Overview.
 
Couchbase Query Workbench Enhancements By Eben Haber
Couchbase Query Workbench Enhancements  By Eben Haber Couchbase Query Workbench Enhancements  By Eben Haber
Couchbase Query Workbench Enhancements By Eben Haber
 
Mindmap: Oracle to Couchbase for developers
Mindmap: Oracle to Couchbase for developersMindmap: Oracle to Couchbase for developers
Mindmap: Oracle to Couchbase for developers
 
N1QL: What's new in Couchbase 5.0
N1QL: What's new in Couchbase 5.0N1QL: What's new in Couchbase 5.0
N1QL: What's new in Couchbase 5.0
 
Extended JOIN in Couchbase Server 4.5
Extended JOIN in Couchbase Server 4.5Extended JOIN in Couchbase Server 4.5
Extended JOIN in Couchbase Server 4.5
 
Introducing N1QL: New SQL Based Query Language for JSON
Introducing N1QL: New SQL Based Query Language for JSONIntroducing N1QL: New SQL Based Query Language for JSON
Introducing N1QL: New SQL Based Query Language for JSON
 
Enterprise Architect's view of Couchbase 4.0 with N1QL
Enterprise Architect's view of Couchbase 4.0 with N1QLEnterprise Architect's view of Couchbase 4.0 with N1QL
Enterprise Architect's view of Couchbase 4.0 with N1QL
 
You know what iMEAN? Using MEAN stack for application dev on Informix
You know what iMEAN? Using MEAN stack for application dev on InformixYou know what iMEAN? Using MEAN stack for application dev on Informix
You know what iMEAN? Using MEAN stack for application dev on Informix
 
Informix SQL & NoSQL: Putting it all together
Informix SQL & NoSQL: Putting it all togetherInformix SQL & NoSQL: Putting it all together
Informix SQL & NoSQL: Putting it all together
 
Informix SQL & NoSQL -- for Chat with the labs on 4/22
Informix SQL & NoSQL -- for Chat with the labs on 4/22Informix SQL & NoSQL -- for Chat with the labs on 4/22
Informix SQL & NoSQL -- for Chat with the labs on 4/22
 
NoSQL Deepdive - with Informix NoSQL. IOD 2013
NoSQL Deepdive - with Informix NoSQL. IOD 2013NoSQL Deepdive - with Informix NoSQL. IOD 2013
NoSQL Deepdive - with Informix NoSQL. IOD 2013
 
Informix NoSQL & Hybrid SQL detailed deep dive
Informix NoSQL & Hybrid SQL detailed deep diveInformix NoSQL & Hybrid SQL detailed deep dive
Informix NoSQL & Hybrid SQL detailed deep dive
 
Table for two? Hybrid approach to developing combined SQL, NoSQL applications...
Table for two? Hybrid approach to developing combined SQL, NoSQL applications...Table for two? Hybrid approach to developing combined SQL, NoSQL applications...
Table for two? Hybrid approach to developing combined SQL, NoSQL applications...
 

Recently uploaded

National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
Wouter Lemaire
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
David Brossard
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
SitimaJohn
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 

Recently uploaded (20)

National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 

N1QL workshop: Indexing & Query turning.

  • 1. N1QLWORKSHOP: INDEXING AND QUERYTUNING IN COUCHBASE 4.0 Keshav Murthy Couchbase Engineering keshav@couchbase.com @N1QL @rkeshavmurthy
  • 2. ©2015 Couchbase Inc. 2 Agenda  Indexing Overview  View Index  GSI Index  Multi Index Scan  Hands On N1QL  QueryTuning with Hands on N1QL  Index Selection Hints  Key-ValueAccess  Joins  Hands On N1QL
  • 4. ©2015 Couchbase Inc. 4 Couchbase Server Cluster Service Deployment 4 STORAGE Couchbase Server 1 SHARD 7 SHARD 9 SHARD 5 SHARDSHARDSHARD Managed Cache Cluster ManagerCluster Manager Managed Cache Storage Data Servic e STORAGE Couchbase Server 2 Managed Cache Cluster ManagerCluster Manager Data Servic e STORAGE Couchbase Server 3 SHARD 7 SHARD 9 SHARD 5 SHARDSHARDSHARD Managed Cache Cluster ManagerCluster Manager Data Servic e STORAGE Couchbase Server 4 SHARD 7 SHARD 9 SHARD 5 SHARDSHARDSHARD Managed Cache Cluster ManagerCluster Manager Query Servic e STORAGE Couchbase Server 5 SHARD 7 SHARD 9 SHARD 5 SHARDSHARDSHARD Managed Cache Cluster ManagerCluster Manager Query Servic e STORAGE Couchbase Server 6 SHARD 7 SHARD 9 SHARD 5 SHARDSHARDSHARD Managed Cache Cluster ManagerCluster Manager Index Servic e Managed Cache Storage Managed Cache Storage Storage STORAGE Couchbase Server 6 SHARD 7 SHARD 9 SHARD 5 SHARDSHARDSHARD Managed Cache Cluster ManagerCluster Manager Index Servic e Storage Managed Cache Managed Cache
  • 5. ©2015 Couchbase Inc. 5 N1QL: Query Execution Flow Clients 1. Submit the query over RESTAPI 8. Query result 2. Parse, Analyze, create Plan 7. Evaluate: Documents to results 3. Scan Request; index filters 6. Fetch the documents Index Servic e Query Service Data Servic e 4. Get qualified doc keys 5. Fetch Request, doc keys SELECT firstname, lastname, state FROM customer WHERE customerid = "customer494"; { "firstName": "Nicolette", "lastName": "Wilderman", "state": "IL“ }
  • 6. ©2015 Couchbase Inc. 6 N1QL: Query Execution Flow Clients 1. Submit the query over RESTAPI 8. Query result 2. Parse, Analyze, create Plan 7. Evaluate: Documents to results 3. Scan Request; index filters 6. Fetch the documents Index Servic e Query Service Data Servic e 4. Get qualified doc keys 5. Fetch Request, doc keys SELECT firstname, lastname, state FROM customer WHERE customerid = "customer494"; { "firstName": "Nicolette", "lastName": "Wilderman", "state": "IL“ }
  • 7. ©2015 Couchbase Inc. 7 N1QL: Inside a Query Service Client FetchParse Plan Join Filter Pre-Aggregate Offset Limit ProjectSortAggregate Index Service Data Service Scan Query Service
  • 8. ©2015 Couchbase Inc. 8 Index Overview: Primary Index  Primary Index  CREATE PRIMARY INDEX PIX_CUST ON customer;  Document key is unique for the bucket.  Primary index is used when no other qualifying index is available or when no predicate is given in the query.  PrimaryScan is equivalent of full table scan "customer": { "ccInfo": { "cardExpiry": "2015-11-11", "cardNumber”:"1212--1234", "cardType": "americanexpress” }, "customerId": "customer534", "dateAdded": "2014-04-06", "dateLastActive”:"2014-05-02”, "emailAddress”:”iles@kertz.name", "firstName": "Mckayla", "lastName": "Brown", "phoneNumber": "1-533-290-6403", "postalCode": "92341", "state": "VT", "type": "customer" } Document key: “customer534”
  • 9. ©2015 Couchbase Inc. 9 Index Overview: Secondary Index  Secondary Index can be created on any combination of attribute names.  CREATE INDEX idx_cust_cardnum customer(ccInfo.cardNumber)  CREATE INDEX idx_cust_postalCode CUSTOMER(postalCode);  Useful in speeding up the queries.  Need to have matching indices with right key- ordering  (ccInfo.cardExpiry, postalCode)  (type, state, lastName firstName) "customer": { "ccInfo": { "cardExpiry": "2015-11-11", "cardNumber”:"1212-232-1234", "cardType": "americanexpress” }, "customerId": "customer534", "dateAdded": "2014-04-06", "dateLastActive”:"2014-05-02”, "emailAddress”:”iles@kertz.name", "firstName": "Mckayla", "lastName": "Brown", "phoneNumber": "1-533-290-6403", "postalCode": "92341", "state": "VT", "type": "customer" } Document key: “customer534”
  • 10. ©2015 Couchbase Inc. 10 Couchbase Indexes for N1QL Fetch Parse Plan Join Filter Offset Limit Project Sort Aggre gate Scan Data Service Global Secondary Index View Indexes Global Secondary Index Global Secondary Index IndexScan IndexScan Data Access Query Service Cluster Map
  • 12. ©2015 Couchbase Inc. 12 View Index 12 APPLICATION SERVER VIEW INDEXER Query Set  DCP based Replication: updates queued for the indexer  View Indexer: Executes incremental map/reduce on a batch of updates  Couchstore based Storage: updates queued for storage  ViewQuery Engine: REST Based queries with filters, limit and more executed with scatter-gather  N1QLView Index: Created via N1QL’sCREATE Index statement  For Beta, View index is the default CREATE PRIMARY INDEX px_customer ON customer USING VIEW; CREATE INDEX idx_cust_postalCode customer(postalCode) USING VIEW ; DROP INDEX customer.idx_cust_postalCode USING VIEW;
  • 14. ©2015 Couchbase Inc. 14 Data Service Projector & Router Global Secondary Index Query Service Bucket#1 Bucket#2 DCP Stream Index Service Supervisor Index maintenance & Scan coordinator Index#2Index#1 Index#4Index#3 ForestDB Storage Engine B u c k e t # 2 B u c k e t # 1
  • 15. ©2015 Couchbase Inc. 15 GSI Index: Key details  SupportedTypes  String, Boolean, Numeric, Nil,Array, Sub-document  Total length of the keys  4 KB – actual length of the key indexed  How the the length is calculated? Does it include the “key name”?  Number of keys  4096! CREATE PRIMARY INDEX px_customer ON customer USING GSI; CREATE INDEX idx_cust_postalCode customer(postalCode) USING GSI; DROP INDEX customer.idx_cust_postalCode USING GSI;
  • 16. ©2015 Couchbase Inc. 16 Query Execution: Plan Fetch Parse Plan Join Filter Offset Limit Project Sort Aggre gate Scan  Each query can be executed in several ways  Create the query execution plan  Access path for each keyspace reference  Decide on the filters to push down  Determine Join order and join method  Create the execution tree  For each keyspace reference:  Look at the available indices  Match the filters in the query with index keys  Choose one or more indices for each keyspace  Create index filters and post scan, post join filters
  • 17. ©2015 Couchbase Inc. 17 Query Execution: Plan Fetch Parse Plan Join Filter Offset Limit Project Sort Aggre gate Scan { "#operator": "IndexScan", "index": "CU_W_ID_D_ID_LAST", "keyspace": "CUSTOMER", … "spans": [ { "Range": { "High": [ "49", "16", ""Montana"" ], "Inclusion": 3, "Low": [ "49", "16", EXPLAIN SELECT c_id, c_first, c_middle, c_last, c_balance FROM CUSTOMER WHERE c_w_id = 49 AND c_d_id = 16 AND c_last = ‘Montana’;
  • 18. ©2015 Couchbase Inc. 18 Query Execution: Plan Fetch Parse Plan Join Filter Offset Limit Project Sort Aggre gate Scan "#operator": "Sequence", "~children": [ { "#operator": "PrimaryScan", "index": "#primary", "keyspace": "reviews", "namespace": "default", "using": "gsi" }, { "#operator": "Parallel", "~child": { "#operator": "Sequence", "~children": [ { "#operator": "Fetch", "keyspace": "reviews", "namespace": "default" }, { SELECT productid, rating, Count(productid) FROM reviews WHERE rating < 3 AND productid BETWEEN "product300" AND "product400" GROUP BY productid, rating;
  • 19. ©2015 Couchbase Inc. 19 Query Execution: Index Scan  PrimaryScan  Equivalent of full table scan in RDBMS  Uses the primary index to scan from start to finish  Index Scan  Index selection is based on the filters and available matching index  Indices with expressions are matched with query expressions  N1QL can use one or more indices per table per query Data Service Global Secondary Index View Indexes IndexScan IndexScan Data Fetch Query Service Cluster Map
  • 21. ©2015 Couchbase Inc. 21 Power Features: Composite Indexes CREATE INDEX ix_last_postal ON PRODUCT(lastName, postalCode, city); SELECT * FROM product WHERE lastname= “Smith” AND postalCode = ‘58292’;  Index scan using composite index: – Needs first N keys to be used to choose the index – Will multiple indexes on same set of columns to support filter push down
  • 22. Power Features: Index Intersection aka Multi Index Scan
  • 23. ©2015 Couchbase Inc. 23 Power Features: IntersectScan (Multi-Index Scan) SELECT * FROM customer WHERE lastName = ’Smith’ AND postalCode = ’94040’;  IntersectScan using multiple indices: – Multiple indices are scanned in parallel – Provides more flexibility in using the indices for filters – Requires less number of indexes defined on table. • Can save on disk space and memory space as well.
  • 24. Switch to Hands On N1QL Page #55
  • 26. ©2015 Couchbase Inc. 26 Query Execution: USE INDEX CREATE INDEX ix_last_postal ON PRODUCT(lastName, postalCode); CREATE INDEX ix_postal_category ON PRODUCT(postalCode,lastName); SELECT * FROM product WHERE lastname= “Smith” AND postalCode = ‘58292’; SELECT * FROM product USE INDEX(ix_last_postal using gsi) WHERE Category = “Smith” AND Name = ‘58292’; Data Service Global Secondary Index View Indexes IndexScan IndexScan Data Fetch Query Service Cluster Map
  • 27. ©2015 Couchbase Inc. 27 Query Execution: USE INDEX CREATE INDEX ix_last ON PRODUCT(lastName) USING GSI; CREATE INDEX ix_postal ON PRODUCT(postalCode) USING GSI; SELECT * FROM product USE INDEX(ix_last USING GSI, ix_postal USING GSI) WHERE Category = “Smith” AND Name = ‘58292’; Data Service Global Secondary Index View Indexes IndexScan IndexScan Data Fetch Query Service Cluster Map
  • 29. ©2015 Couchbase Inc. 29 Power Features: USE KEYS Data Service Global Secondary Index View Indexes Global Secondary Index Global Secondary Index KeyScan IndexScan IndexScan Data Fetch Query Service Cluster Map
  • 30. ©2015 Couchbase Inc. 30 Power Features: USE KEYS SELECT customerId, lastName, firstName FROM customer USE KEYS [‘customer494’];  KeyScan: Directly use the Couchbase cluster map to get the document  You can give one or more values in the array  From N1QL, get keys via: META(customer).id
  • 32. ©2015 Couchbase Inc. 32 Functional Indices "contacts": { "age": 46, "children": [ { "age": 17, "fname": "Aiden", "gender": "m" }, { "age": 2, "fname": "Bill", "gender": "f" } ], "email": "dave@gmail.com", "fname": "Dave", "hobbies": [ "golf", "surfing" ], "lname": "Smith", "relation": "friend", "title": "Mr.", "type": "contact" CREATE INDEX idx_lname_lower ON contacts(LOWER(lname)) using GSI; SELECT count(*) FROM contacts WHERE lower(lname) = smith;
  • 33. ©2015 Couchbase Inc. 33 Functional Indices "contacts": { "age": 46, "children": [ { "age": 17, "fname": "Aiden", "gender": "m" }, { "age": 2, "fname": "Bill", "gender": "f" } ], "email": "dave@gmail.com", "fname": "Dave", "hobbies": [ "golf", "surfing" ], "lname": "Smith", "relation": "friend", "title": "Mr.", "type": "contact"  The value indexed is the result of the function or expression.  The query has to use the same expression in the WHERE clause for the planner to consider using the index.  Use EXPLAIN to verify using the index.
  • 35. ©2015 Couchbase Inc. 35 Indexes on Arrays cbq> select contacts.children from contacts limit 1; { "requestID": "e61a011f-2387-47d3-aee0-7bfd874ed2bf", "signature": { "children": "json" }, "results": [ { "children": [ { "age": 17, "fname": "Aiden", "gender": "m" }, { "age": 2, "fname": "Bill", "gender": "f" } ] } ], CREATE INDEX idx_ctx_children ON contacts(children) USING GSI; select * from system:indexes where name = "idx_ctx_children"; "indexes": { "datastore_id": "http://127.0.0.1:8091", "id": "ea6023a0dd24bedc", "index_key": [ "`children`" ], "keyspace_id": "contacts", "name": "idx_ctx_children", "namespace_id": "default", "state": "online", "using": "gsi" }
  • 36. ©2015 Couchbase Inc. 36 Indexes on Arrays cbq> select contacts.children from contacts limit 1; { "requestID": "e61a011f-2387-47d3-aee0-7bfd874ed2bf", "signature": { "children": "json" }, "results": [ { "children": [ { "age": 17, "fname": "Aiden", "gender": "m" }, { "age": 2, "fname": "Bill", "gender": "f" } ] } ], select * from contacts where children[0] = {"age":17, "fname":"Xena", "gender":"f"}; select * from contacts c unnest c.children as anychild where anychild = {"age":17, "fname":"Xena", "gender":"f"};
  • 37. ©2015 Couchbase Inc. 37 Indexes on Arrays cbq> select contacts.children from contacts limit 1; { "requestID": "e61a011f-2387-47d3-aee0-7bfd874ed2bf", "signature": { "children": "json" }, "results": [ { "children": [ { "age": 17, "fname": "Aiden", "gender": "m" }, { "age": 2, "fname": "Bill", "gender": "f" } ] } ], select * from contacts where children = [ { "age": 17, "fname": "Xena”, "gender": "f”}, {"age": 2,"fname": "Yuri”,"gender": "m”} ];
  • 39. ©2015 Couchbase Inc. 39 Query Execution: Join "CUSTOMER": "customer": { "ccInfo": { "cardExpiry": "2015-11-11", "cardNumber": "1212-1221-1121-1234", "cardType": "americanexpress" }, "customerId": "customer285", "dateAdded": "2014-04-06T15:52:16Z", "dateLastActive": "2014-05-06T15:52:16Z", "emailAddress": "jason_skiles@kertzmann.name", "firstName": "Mckayla", "lastName": "Brown", "phoneNumber": "1-533-290-6403 x2729", "postalCode": "92341", "state": "VT", "type": "customer" } Document key: “customer285” Document key: “purchase1492” “purchases”:{ "customerId": "customer285", "lineItems": [ {"count": 3, "product": "product55”}, {"count": 4, "product": "product169”},], "purchaseId": "purchase7049", "type": "purchase” } "purchases": { "customerId": "customer285", "lineItems": [ { "count": 5, "product”: "prod551" }, { "count": 3, "product": "product549" }, ], "purchaseId": "purchase3648", "purchasedAt": "2013-11-07T15:52:38Z", "type": "purchase" } Document key: “purchase583”
  • 40. ©2015 Couchbase Inc. 40 Joins SELECT c.customerid, Count(*) totpurchases FROM purchases p INNER JOIN customer c ON KEYS p.customerid GROUP BY c.customerid ORDER BY count(*) DESC limit 10; Two keyspace joins ON Clause for the join Fetch Parse Plan Join Filter Offset Limit Project Sort Aggre gate Scan
  • 41. ©2015 Couchbase Inc. 41 Joins SELECT c_id, c_first, c_middle, c_last, (c_max - c_balance) FROM CUSTOMER USE KEYS [‘1.10.1938’]; Fetch Parse Plan Join Filter Offset Limit Project Sort Aggre gate Scan SELECT c_id, c_first, c_middle, c_last, (c_max - c_balance) FROM CUSTOMER USE KEYS [to_string($1)|| “.” || to_string($2) || “.” || to_string($3)];
  • 42. ©2015 Couchbase Inc. 42 N1QL: Join SELECT * FROM ORDERS o INNER JOIN CUSTOMER c ON KEYS (o.O_C_ID) LEFT JOIN PREMIUM p ON KEYS (c.C_PR_ID) LEFT JOIN demographics d ON KEYS (c.c_DEMO_ID) Fetch Parse Plan Join Filter Offset Limit Project Sort Aggre gate Scan  Support INNER and LEFT OUTER joins  Join order follows the order in the FROM clause.  N1QL supports the nested loop joins now.  Join is always from a key of one document(outer table) to the document key of the second document (inner table)
  • 43. Switch to Hands On N1QL Page #71
  • 44. ©2015 Couchbase Inc. 44 Summary  Create indices with right set of keys  Important to analyze your workload  Primary Scan = FullTable Scan  Indexes are maintained asynchronously.  Set the right consistency level for your query  Design your primary keys and document references correctly.  USE KEYS will get you the data fast  EXPLAIN to understand query plan  Take control when you must, USE INDEX hint

Editor's Notes

  1. Data-parallel — Query latency scales up with cores Memory-bound
  2. View Indexes: Incremental Map/Reduce with customer JavaScript for complex indexing logic for online reporting and analytics GSI (Global Secondary Indexes): Efficient indexes for secondary lookups and ad-hoc query processing
  3. Projector and Router: 1 Projector and Router per node 1 stream of changes per buckets per supervisor Supervisor 1 Supervisor per node Many indexes per Supervisor
  4. PrimaryScan Equivalent of full table scan in RDBMS Uses the primary index to scan from start to finish Equivalent of full table scan in RDBMS