Top Banner
Introducing N1QL — SQL for Documents Gerald Sangudi | Couchbase @sangudi
24

Couchbase Live Europe 2015: Introducing N1QL – SQL for Documents

Jul 16, 2015

Download

Software

Couchbase
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Couchbase Live Europe 2015: Introducing N1QL – SQL for Documents

Introducing N1QL — SQL for Documents

Gerald Sangudi | Couchbase@sangudi

Page 2: Couchbase Live Europe 2015: Introducing N1QL – SQL for Documents

©2015 Couchbase Inc. 2

Agenda

N1QL sessions today

What is N1QL

Language highlights

Architecture

Ecosystem

Next steps

Q & A

Page 3: Couchbase Live Europe 2015: Introducing N1QL – SQL for Documents

©2015 Couchbase Inc. 3

N1QL Sessions Today

Introduction

Hands on workshops (“Querying Big Data”)

Performance and scaling tips

Client-side development

Page 4: Couchbase Live Europe 2015: Introducing N1QL – SQL for Documents

What is N1QL?

Page 5: Couchbase Live Europe 2015: Introducing N1QL – SQL for Documents

©2015 Couchbase Inc. 5

What is N1QL?

N1QL is a new query language that systematically

extends SQL to document-oriented data

N1QL extends SQL to handle data that is:

Nested: Contains nested objects, arrays

Heterogeneous: Schema-optional, non-uniform

Distributed: Partitioned across a cluster

Page 6: Couchbase Live Europe 2015: Introducing N1QL – SQL for Documents

©2015 Couchbase Inc. 6

What is N1QL?

6

Document Model: Richness and Flexibility

SQL: Expressiveness and Soundness

N1QL is SQL for Documents

Page 7: Couchbase Live Europe 2015: Introducing N1QL – SQL for Documents

Language Highlights

Page 8: Couchbase Live Europe 2015: Introducing N1QL – SQL for Documents

©2015 Couchbase Inc. 8

SELECT

Standard SELECT pipeline

SELECT, FROM, WHERE, GROUP BY, ORDER BY, LIMIT, OFFSET

JOINs (by keys)

Subqueries

Aggregation

Set operators

UNION, INTERSECT, EXCEPT

EXPLAIN

Page 9: Couchbase Live Europe 2015: Introducing N1QL – SQL for Documents

©2015 Couchbase Inc. 9

Indexing

CREATE / DROP INDEX

Two types of indexes

View indexes

GSI indexes (new secondary indexes)

Page 10: Couchbase Live Europe 2015: Introducing N1QL – SQL for Documents

©2015 Couchbase Inc. 10

Data writes*

UPDATE

UPDATE … WHERE …

DELETE

DELETE … WHERE …

INSERT

INSERT … VALUES …

INSERT … SELECT …

MERGE

*Experimental in CB 4.0.

*Single-document atomicity.

Page 11: Couchbase Live Europe 2015: Introducing N1QL – SQL for Documents

©2015 Couchbase Inc. 11

Document-oriented Extensions Nested

Paths—user.profile.email, children[0], children[0:2]

NEST, UNNEST

Ranging—FOR EVERY child IN children

Transformations—SELECT {“name”: first_name || last_name}

Non-uniform

IS MISSING

Type checking and conversion

Distributed

Direct lookup—USE KEYS

Efficient joins—ON KEYS

Page 12: Couchbase Live Europe 2015: Introducing N1QL – SQL for Documents

Architecture

Page 13: Couchbase Live Europe 2015: Introducing N1QL – SQL for Documents

©2015 Couchbase Inc. 13

Topology

Client SDK

App

Index

CB Node

ODBC / JDBC

App

Query

Manager

Data

Index

CB Node

Query

Manager

Data

Index

CB Node

Query

Manager

Data

Index

CB Node

Query

Manager

Data

Index

CB Node

Query

Manager

Data

Index

CB Node

Query

Manager

Data

Connectivity, ecosystem, & rich apps

Node services & modular scaling

Query throughput scales with nodesODBC / JDBC

BI Tool

Page 14: Couchbase Live Europe 2015: Introducing N1QL – SQL for Documents

©2015 Couchbase Inc. 14

Inside a Cluster

Index Services

Clients

Data Services

(1) Request (6) Response

Query Services

(2) Plan: Query to execution plan (5) Evaluate: Documents to results

(3) Scan: Attributes to keys (4) Fetch: Keys to documents

Page 15: Couchbase Live Europe 2015: Introducing N1QL – SQL for Documents

©2015 Couchbase Inc. 15

Inside a Query Node

Index Services

Client

Data Services

FetchScanParse Plan Join Filter

Pre-Aggregate

Offset Limit Project

Data-parallel — Query latency scales with cores

Memory-bound

Pluggable architecture — datastore, indexer, client, …

Request Response

SortAggregate

Page 16: Couchbase Live Europe 2015: Introducing N1QL – SQL for Documents

©2015 Couchbase Inc. 16

Data Service

Projector & Router

Secondary Indexing

Index Scan

Query ServiceIndex Service

SupervisorIndex maintenance &

Scan coordinator

Index#2Index#1

Query Engine

Bucket#1 Bucket#2

DCP StreamIndex#4Index#3

...

Bucket#2

Bucket#1

Page 17: Couchbase Live Europe 2015: Introducing N1QL – SQL for Documents

Ecosystem

Page 18: Couchbase Live Europe 2015: Introducing N1QL – SQL for Documents

©2015 Couchbase Inc. 18

Ecosystem

xDBC

App

CB Node

xDBC

ETL

xDBC

BI

xDBC

Visualization

CB Node CB Node

Standards-based drivers

Integrations, partnerships

Page 19: Couchbase Live Europe 2015: Introducing N1QL – SQL for Documents

Next steps

Page 20: Couchbase Live Europe 2015: Introducing N1QL – SQL for Documents

©2015 Couchbase Inc. 20

Roadmap

DP1

DP2

DP3

DP4

CB4.0 DP

CB4.0 BetaCB4.0 GA

9/2013

2014

Q1

CB Live London2015

Page 21: Couchbase Live Europe 2015: Introducing N1QL – SQL for Documents

©2015 Couchbase Inc. 21

Resources

©2014 Couchbase, Inc. 21

query.couchbase.com

Downloads

Tutorial

Forums

Resources

@N1QL, @couchbase

Stack Overflow

Page 22: Couchbase Live Europe 2015: Introducing N1QL – SQL for Documents

Q & A

Page 23: Couchbase Live Europe 2015: Introducing N1QL – SQL for Documents

Thank you.

Gerald Sangudi | Couchbase@sangudi

Page 24: Couchbase Live Europe 2015: Introducing N1QL – SQL for Documents

©2015 Couchbase Inc. 24