getting started with apache ignite sql
play

Getting Started With Apache Ignite SQL Denis Magda, GridGain - PowerPoint PPT Presentation

Getting Started With Apache Ignite SQL Denis Magda, GridGain Developer Relations Igor Seliverstov, GridGain Architecture Group Topics Ignite SQL Basics: DML, DDL, connectivity, configuration Affinity Co-Location and Distributed JOINs


  1. Getting Started With Apache Ignite SQL Denis Magda, GridGain Developer Relations Igor Seliverstov, GridGain Architecture Group

  2. Topics • Ignite SQL Basics: DML, DDL, connectivity, configuration • Affinity Co-Location and Distributed JOINs • Beyond Memory Capacity: Disk Tier Usage and Memory Quotas • Ignite SQL Evolution With Apache Calcite

  3. Ignite SQL Basics

  4. Ignite SQL = ANSI SQL at Scale • ANSI-99 DML and DDL syntax – SELECT, UPDATE, CREATE… • Distributed joins, grouping, sorting • Schema changes in runtime – ALTER TABLE, CREATE/DROP INDEX • Works with in-memory and disk-only records – If Ignite Persistence is used as a disk tier

  5. Connectivity Options • Thick Client APIs – Java, C#/.NET, C++ • JDBC and ODBC drivers • Thin Client APIs – Multi-language support

  6. Configuration Option #1: Programmatically With Annotations Usage Scenario: • Spring-style development by annotating POJOs • DDL can be used to apply changes in runtime.

  7. Configuration Option #2: Spring XML With Query Entities Usage Scenario: • Ignite as a cache that writes-through changes to an external database. • DDL can be used to apply changes in runtime.

  8. Configuration Option #3: In Pure SQL With DDL Usage Scenario: • SQL-driven applications • Green-field applications using Ignite as a database with its native persistence

  9. Demo Time Cluster Startup and Database Creation

  10. Affinity Co-Location and Distributed JOINs

  11. Ignite SQL Engine Internals Ignite SQL Ignite SQL H2 Engine H2 Engine Data & Indexes Data & Indexes Ignite SQL H2 Engine Data & Indexes

  12. Query Execution Phases Map City Reduce Map Map Thick Client City Reduce

  13. Default Data Distribution France Canada Marseille Toronto Montreal Paris Ottawa Calgary City Country Table Table

  14. SQL JOIN With Data Shuffling 2 Canada Toronto Paris Calgary Paris 3 Ottawa Thick Client Montreal 2 France 1 & 4 Marseille Ottawa 1. Initiating Execution Montreal 2. Execution on Servers (map phase) 3. Data Shuffling 4. Reduce Phase

  15. Co-Located Distribution (aka. Affinity Co-Location) France Canada Toronto Marseille Montreal Paris Ottawa Calgary City Country Table Table

  16. All You Need is to Configure Affinity Key

  17. Affinity Key to Node Mapping Process Application Process Network Call City Record Affinity Key Partition Node

  18. High-Performance SQL JOIN 2 Canada Toronto Ottawa Calgary Thick Client 2 France 1 & 3 Marseille 1. Initiating Execution Paris 2. Execution on Servers (map phase) 3. Reduce Phase

  19. Demo Time Queries With JOINs

  20. Beyond Memory Capacity: Disk-Tier and Memory Quotas

  21. Multi-Tier Storage architecture 1. In-Memory - General in-memory caching, high-performance computing 2. In-Memory + Native Persistence - Ignite as an in-memory database 3. In-Memory + External Database - Acceleration of services and APIs with write-through and write-behind capability

  22. Multi-Tier Storage Architecture Memory segment Index Page Data page Leaf page Metadata page Leaf page Data page Metadata page (root) Data page Index Page (root) Key-Value Index page Key-Value Inner page 2 (inner) Key-Value Index Page Leaf page 2 Leaf page 3 (leaf) Key-Value Index Data

  23. Multi-Tier Storage Architecture Memory segment Data page #5 Inner page Leaf page Metadata page Leaf page Data page #2 Metadata page Data page #0 Data page #1 Data page #2 Data page #3 Data page #4 Data page #5 Data page #6 Partition file with Data Pointer in a memory segment Pages map (read/write ops) PageId Position in a file (load page/checkpoint)

  24. Java off-heap vs Java heap Heap Planning Parsing Heap SQL query processing Scanning (index or table scan) Computing Off-heap (filters, joins, expressions) More Heap

  25. Java off-heap vs Java heap τ max_pop Sorting Here we need full set in heap ρ name, name0, max_pop Renaming country.name, city.name ℱ MAX(city.population) Aggregation π country.name, city.name, city.population Projection Here we need full set in heap too ⋈ country.code = city.countrycode Join σ code in (‘CAN’, ‘FRA’) Filtering CITY COUNTRY Scanning

  26. Query memory quotas How to configure:

  27. Interim results offloading τ max_pop Why don’t you flush result Sorting sets to disk? ρ name, name0, max_pop Renaming And it country.name, city.name ℱ MAX(city.population) Aggregation π country.name, city.name, city.population Projection ⋈ country.code = city.countrycode Join σ code in (‘CAN’, ‘FRA’) Filtering CITY COUNTRY Scanning

  28. Intermediate results offloading How to configure:

  29. When you need quotas/offloading enabled ● Sorting (ORDER BY) ● Grouping (DISTINCT, GROUP BY) ● Complex subqueries

  30. Demo Time Running SQL Over Disk-Only Records

  31. Apache Ignite SQL Evolution With Apache Calcite

  32. Why do we need it? Here we need Map-Reduce phase too Here we need Map-Reduce phase

  33. Typical execution flow Result Schema User SQL Query Validation Validator Parser Dictionary Query AST Statistics RBO CBO Rule-based Cost-based Optimizer mode optimizer optimizer Query plan Row source generator Execution

  34. Apache Calcite JDBC Client JDBC Server Metadata SPI Optional SQL Parser/Validator Need to implement: Core Query optimizer ● Splitter ● Runtime Pluggable 3rd party ops 3rd party ops Plugable ● Indexes support rules ● DML support ● DDL support 3rd party 3rd party data data

  35. Query Parser and Transformer Relational operators tree (query plan) π p.id, p.name τ p.name DESC Query AST Select expr= p.id, d.name σ p.id > 10 OR p.id < 10000 from= person, dep ⋈ p.depId = d.id cond= p.depId = d.id AND (p.id > 10 OR p.id < 10000) person(p) dep(d) order = p.name DESC offset= 10

  36. Cost-Based Optimizer Query AST (from parser) Query transformer Relational tree Statistics Dictionary Estimator Equivalent Relational tree relational + costs tree Plan generator Rules Query plan (to Row source generator)

  37. Cost-Based Splitter Root π p.id, p.name τ p.name DESC σ p.id > 10 OR p.id < 10000 ⋈ p.depId = d.id person(p) dep(d)

  38. Reactive Execution Flow Network communication Push Push Send Push Data flow Scan Filter Sender Receiver Client cursor Backpressure Request Request Acknowledge Request Node buffer Node buffer Node buffer Node buffer

  39. Demo Time Calcite Prototype Demo With Sub-Queries

  40. Learn More • Apache Ignite SQL https://apacheignite-sql.readme.io/docs – • Memory Quotas (available in GridGain Community Edition): https://www.gridgain.com/docs/latest/developers-guide/me – mory-configuration/memory-quotas • Demos shown in this webinar https://github.com/GridGain-Demos/ignite-sql-intro-samples – • New Apache Calcite-based engine https://cwiki.apache.org/confluence/display/IGNITE/IEP-37%3A+New+ – query+execution+engine

Recommend


More recommend