Upload
keshav-murthy
View
153
Download
0
Embed Size (px)
Citation preview
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2017. All rights reserved.
QUERY WORKBENCH IMPROVEMENTSWhat’s New in Couchbase 5.0
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2017. All rights reserved. 2
Eben Haber
Senior Software Engineer & User Advocate
LinkedIn – https://www.linkedin.com/in/ebenhaber
Your Presenter
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2017. All rights reserved.
OBJECTIVES1
2
3
Query Workbench
Query Monitoring
Demo
3
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2017. All rights reserved.
1QUERY WORKBENCH ENHANCEMENTS
4
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2017. All rights reserved. 5
Query Plans in the Query Workbench
• Plans help explain query performance
• New “Explain” button – get the query plan without
adding “explain” keyword
• Workbench also automatically runs “Explain” with
every query. Plans stored in the Query History, so
you can re-examine plans from prior queries
• Workbench queries also set ‘collect timings’
parameter, plan result shows time spent in each
operator
• Even better, now supports visual query plans
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2017. All rights reserved. 6
Visual Query Plan
6
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2017. All rights reserved. 7
Visual Query Plan (Explain)
Textual query plans are lengthy and hard to read. Version 5.0 now supports Visual query plans.
Shows the query execution plan in easy to understand visual flow diagrams and additionally provide other useful information.
Each visual query plan displays
• summary of buckets, fields, indexes used in query
• visual tree of query operators,
After query execution, can show:
• time spent per operator
• cost of each operator as a percentage of the total cost of the plan
• number of items processed (input & output)
• highlighted expensive operators
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2017. All rights reserved. 8
Schema Inferencing/INFER
• No fixed schemas in Couchbase
• Document structure can evolve as the developer sees fit
• Yet documents usually share common structure(s)
• INFER command (added in 4.5) randomly samples documents from a bucket,
produces schema(s) (compatable with http://json-schema.org)
• Based on a random sample, schemas are a “guess”, may miss rare elements
• In 5.0:
• Workbench automatically infers schemas for each bucket in background
• Schemas come up more quickly in Bucket Insights Panel
• Field/Index names available for auto-completion when writing queries
• Workbench also shows document counts for each bucket
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2017. All rights reserved. 9
Schema Inferencing and Query Checking
• Couchbase has no fixed schema, can’t normally detect typos/non-existent fields
• Instead of a syntax error, you get unexpected result
• Release 5.0 has partial solution:
• Workbench automatically does schema inferencing (INFER) on each bucket.
• Inferred schema, combined with query plan, can identify some misspelled/incorrect field names
• False positives for very rare fields, not found by INFER
• False negatives for nested queries and expressions (e.g., ARRAY) not processed in query plan
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2017. All rights reserved. 10
Query History maintains a history of all
the queries executed on the Query
Workbench
• scroll through the history window or
use arrow keys at the top of the
editor to navigate
• search the query history by entering
a text in the search box located on
the top
• delete the currently selected query
from the history
• delete all the entire query history
Enhanced Query History
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2017. All rights reserved. 11
Query Preferences
Query Preferences provides you with ability to
change the run-time settings for Query Service
through Run-Time Preferences window
- Collect query timings
- Max Parallelism
- Scan Consistency
- Positional Parameters
- Named Parameters
- (or regular query HTTP params, if “$” omitted)
- Query Timeout (default 5 min)
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2017. All rights reserved. 12
Query Import/Export
Query Import/Export provides you with tools to
• Load the saved query from a file into the Query
Editor
• Export the query statement in the .txt format
• Export the query results in the JSON format
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2017. All rights reserved.
2QUERY MONITORING
13
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2017. All rights reserved. 14
Query Monitoring
Since 4.5, Couchbase provided node-specific query information: e.g., system:active_requests
In 5.0, global query information, i.e. details of queries that are “active” (currently running), “completed” (recently run), or “prepared” (aggregate statistics for prepared queries) and ability to cancel/kill long-running queries.
Query Monitoring UI displays
• Active Queries – all running queries are displayed, with details such as the query text, the node IP address, duration, request identification number, and the current state of the query. Additionally, provide ability to cancel a long running query.
• Completed Queries – all completed queries that took longer than 1 second, with details as above plus result count and timestamp.
• Prepared Queries - aggregate statistics for prepared queries, e.g., query syntax, average elapsed time, and number of invokations.
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2017. All rights reserved. 15
Query Monitoring
15
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2017. All rights reserved.
3 DEMO !!!
16
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2017. All rights reserved.
THANK YOU!