החדשות החלון פונקציותSQL Server 2012 רשף גריDBA אפליקטיבי– הפועלים בנק בלוגים, פורומים, לינקדאין, וקישורים כישורים: http://About.me/GeriReshef 1
פונקציות החלון החדשות SQL Server 2012
גרי רשף
DBA בנק הפועלים–אפליקטיבי
:כישורים וקישורים, לינקדאין, פורומים, בלוגים
http://About.me/GeriReshef
1
פונקציות החלון החדשות SQL Server 2012
?מה בתוכנית
?כך כל מעניינות הן ומדוע החלון פונקציות מהן•
SQL-ב החלון פונקציות :הראשון הגל• Server 2005
SQL-ב החלון פונקציות :השני הגל• Server 2012
?בעתיד מצפים אנו למה :השלישי הגל•
..סיכומים ,הערות ,שאלות•
פונקציות החלון החדשות SQL Server 2012
כלי פיתוח
,VB -)?איך( פרוצדורליות שפות• C, Java
SQL -)?מה( דקלרטיביות שפות•
?החלון לפונקציות הקשר מה•
2
פונקציות החלון החדשות SQL Server 2012
הגלים השונים
2005
פונקציות צבירהSum
Count
Max/Min
Avg
2005פונקציות ספירהRow_Number
2012פונקציות חדשות
Lag
2012פונקציות חדשות
First_Value
2012
ארגומנטים חדשים
Frame
פונקציות החלון החדשות SQL Server 2012
Window Vs. FrameQuantityMonthCustomer
…1Adva
…2Adva
…4Adva
…5Adva
…4Beni
…2Carmel
…3Carmel
…5Carmel
3
פונקציות החלון החדשות SQL Server 2012
Running
Total Range
Running
Total Row
QuantityMonthYearCustomer
130808012011Dana
1301305012011Dana
3202209022011Dana
3202402022011Dana
3202703022011Dana
3203205022011Dana
3603604032011Dana
Row Vs. Range
פונקציות החלון החדשות SQL Server 2012
יתרונות וחסרונות–נקודות לסיכום
מסובכות לבעיות פשוטים פתרונות•
מקוריים פתרונות•
בעייתיים ביצועים•
"חורים"ב לקוי טיפול•
4
?שאלות!תודה רבה
http://About.me/GeriReshef
5
Introducing
SQL Server
2012 Extended
Events
Enhancements
Keren Bartal
Tzahi Hakikat
888 holdings
Agenda
• About us
• Introduction to Extended Events
• Extended Events 2008
• Extended Events Practical Terminology
• Extended Events 2012 Enhancements
• Summary
6
Agenda
• About us
• Introduction to Extended Events
• Extended Events 2008
• Extended Events Practical Terminology
• Extended Events 2012 Enhancements
• Summary
About 888
• 888.com is a global online gaming company.
• Our purpose is to provide quality
entertainment for people who enjoy
gambling.
• Giving them the opportunity to do so in a safe,
fun, fair, regulated and secure environment.
7
888 Database Environment
50 Production Instances
300 Development Instances
400 Databases
250 TB Of Data
24*7 Availability
99.95 Uptime
8
Agenda
• About us
• Introduction to Extended Events
• Extended Events 2008
• Extended Events Practical Terminology
• Extended Events 2012 Enhancements
• Summary
Extended Events
• General event-handling system for windows
servers
• Used for problem diagnosis and info gathering
and auditing
• The Extended Events infrastructure supports
the correlation of data from SQL Server and
OS
9
Extended Events
• Support 7 different types of targets
• Event and consumer agnostic
– Any event can be processed by any consumer
– New events can be added, immediately useable
• Rich predicate system for filtering
• Less overhead than server-side trace queues
– 10,000 events processed will consume 1% of
single 2GHz processor
Agenda
• About us
• Introduction to Extended Events
• Extended Events 2008
• Extended Events Practical Terminology
• Extended Events 2012 Enhancements
• Summary
10
Extended Events 2008
אוהבים לכתוב בסינטקס שנראה כמו כתב •
?סתרים כנעני
לא נותן לכם מה שאתם Profiler-מרגישים שה•
?צריכים
.מה אכפת לי, תירו לעצמכם ברגל, קדימה•
?ל "של מי הציטוט הנ•
Extended Events 2008
drawbacks
• XE required extensive understanding of
system catalog views and DMVs
• Event Sessions could only be managed
through the use of DDL commands
• Reading target data requires the use of
XQuery
11
Extended Event Metadata
• Catalog views for defined session info– server_event_sessions
– server_event_session_target
– server_event_session_fields
– server_event_session_actions
– server_event_session_events
• DMVs for Event System Metadata– dm_xe_package
– dm_xe_objects
– dm_xe_object_columns
– dm_xe_map_values
• DMVs for currently active session info– dm_xe_sessions
– dm_xe_session_targets
– dm_xe_events
– dm_xe_event_actions
– dm_xe_object_columns
Demo
Capture errors with XE 2008
• Find events and actions
• Create a new event session
• View the output
12
Agenda
• About us
• Introduction to Extended Events
• Extended Events 2008
• Extended Events Practical Terminology
• Extended Events 2012 Enhancements
• Summary
Extended Events Objects
Module
Packages
Events Targets Actions Types Predicates Maps
13
Packages
• Packages are metadata containers
• Packages register at module load time
• 9 available packages
• package0 - XE system objects (default)
• sqlserver - SQL Server related objects
• sqlos - SQL Server Operating System (SQLOS) related
objects
• SQL audit uses private XE package
Events
• An event is a well known point in code
• Unique schema for each event
• Supports optional fields
• Events fire synchronously
• 264 events in 2008 R2
• 618 events in 2012
14
Actions
• programmatic response or series of responses
to an event
• Can be added to any event
• Adds data to the event payload
• Actions are invoked synchronously
• Trigger a memory dump
Demo
Capture errors using the XE UI
• Create an event session
• Configure action
• Watch live data
15
Targets
• Target is an event consumer
– Can be synchronous or asynchronous
• Target types
– event_file
– event_counter
– histogram
– etw_classic_sync_target
– pair_matching
– ring_buffer
– event_stream
Demo
Monitor locks
Present different types of targets
• Ring buffer
• Event file
• Event counter
• Histogram
• Pair Matching
• Etw_classic_sync_target
16
Predicates
• Predicates are a set of logical rules that are
used to evaluate events when they are
processed.
• Boolean expressions using flexible operators
• Event data
• Action data
• Global State
Demo
Activity Tracking
Present different types of Predicates
• Event Predicates
• Action Predicates
• Global Predicates
17
Event Session
• The materialization of combination of metadata
elements of XE architecture
• Multiple targets per session
• Event can be in many sessions
– Actions/Predicates are per event
• Event Session can specify what to do if target can't
keep up
• Event Session defines data retention
• Event session can add or remove events on runtime
Event Session
18
Event life cycle
Pre-Collect
IsEnabled check
Publish
Actions executed Synchronous targets served Event data buffered for asynchronous targets
Collection
Customizable attribute check
Predicate evaluation
Predicate evaluation
Event data collected
Agenda
• About us
• Introduction to Extended Events
• Extended Events 2008
• Extended Events Practical Terminology
• Extended Events 2012 Enhancements
• Summary
19
Extended Events 2012
Enhancements
• User Interface
– Advanced & Wizard UI for creating and managing
– Display & Analysis
• Expanded to other systems
– Analysis Services, Replication, PDW
• Managed code
– Powershell object model for runtime and meta data
– Reader API for XEL files and near real time stream
User Interface
• Event Session list
– Provides a list of Event Sessions
• New Session Wizard
– Provides a simplified experience for creating an
Event Session
• Extended Events display
– Tabbed windows that display Extended Events
trace data
20
Demo
Capture queries and group by query hash
• Grouping
• Aggregation
• Save XE to a table
Extended Events Management
API
• Management API provides the ability to create
and modify event sessions
• Provides a complete object model for XE
usage by managed applications
• Provides a XEReader API for reading event files
and event streams coming from a running
event session on a server
21
Agenda
• About us
• Introduction to Extended Events
• Extended Events 2008
• Extended Events Practical Terminology
• Extended Events 2012 Enhancements
• Summary
Extended Event Use Cases
• Proactive monitoring
– Application errors
– Errors log
– Event grouping
• Troubleshooting
– Page Split
– blocking
• Audit
– Monitor the access of privileged and non privileged users
22
The Profiler’s grave
Summary
• SQL Server 2012 offers simplified diagnostic tracing with Extended Events
– Management Studio integration provides SQL Server Profiler functionality for Extended Events allowing Event Sessions to be created, modified, and scripted
– Management API allows managed applications to be developed that leverage Extended Events
23
24
סיפורו של חוזר
איך :בתשובה
-השתכנעתי ש
DAC הולך
לשנות את חיי
DBA-ה
?מה בתוכנית
ולמה שלחתי אותו לישון בסלון DACמה זה •
מה קרה בשנה האחרונה•
הדגמה•
25
Challenges
Development
• No uniform DB
project system and
workflow
Deployment
• DBAs and
Developers work in
silos
• Time consuming and
error prone
Management
• Difficult to centrally
control the
environment
Investments
Development
• Data-tier Application
project
• Integrated editor, debugger,
IntelliSense, policy designer
• Static code analysis, build
service
Deployment
• Easier to deploy
and upgrade Data-
tier Apps from VS
and SSMS (and now
SSDT)
level
Management
• Manage @ Scale: SQL
Server Control Point
• Visualize resource
utilization at the
instance & application
level
26
Concepts
.dacpac = unit of deployment (data-
tier application + developer intent)
Data-tier Application Component
• Improves collaboration between
developer and DBA
• Moves developers from a procedural
model to a declarativemodel
V1 is targeted at small apps
Schema
UDFs
LOGICA
L
Tables,
Views,
Procs,
UDFs
PHYSIC
AL
Users,
Logins,
Indexes
DAC Deployment
Profile
Deployment
Requirements,
Management Policies
Data-Tier Applications
Data-Tier Applications
• Often referred to as the DAC Framework (or DAC Fx)
• Collection of APIs, file and data formats, and services
• Dramatically simplify database deployment and versioning
• Fully integrated into SSDT and essential for developers!
• Allows a focus on the data model rather than on scripts
• Target on-premises or cloud
27
הרהורי כפירה
•Enterprise Edition Only )כחלק מ-UCP(
לא היתה תמיכה בכל האובייקטים•...וכל האובייקטים התלויים בהם•
AdventureWorks-אפילו לא ב•
DAC :Side by Sideשדרוג באמצעות •
Data-אין תמיכה ב•
אין תמיכה בגרסאות ישנות•
?מה השתנה
v2 DAC Upgrade
• Side-by-side process
• Data migrated to new database
• Retained copy of previous databasev3 DAC Upgrade
• Shipped with SQL Server 2012
• Supports in-place upgrades
• No need to copy/migrate all the data (#1 requested feature)
• Support for SQL Server 2005 SP4 (or later) and SQL Azure
• Need to ensure sufficient transaction log space is available for upgrade process
• PowershellIncrementalUpgrade() method added
28
Enhanced Object Support
Significant enhancement to list of supported
objects
• 98% SQL Azure parity
• Support added for permissions and roles
Enhanced database object support:
Newly Supported Objects
SYNONYM SEQUENCE
SPATIAL INDEX GEOMETRY
GEOGRAPHY HIERARCHYID
Cursor Parameters in Stored Procedures STATISTICS
Platform Targeting
Single project can target multiple platforms
• Versions of SQL Server
• SQL Azure
Build prevents use of unsupported features
for platform
Easy migration of databases to SQL Azure
• Create down-level .dacpac file
29
Demo
Database Project vs. DAC ProjectData-tier Application Project V1
(Small Apps)
Visual
Studio
Build
.dacpac
Database Project(Mission Critical, Business Critical)
Visual
Studio
.dbschema
Build
Deploy
y
Deplo
y
Generate
scripts
30
DAC Exports
Option to export both schema and data to a single file
• Exports logins, users, tables, columns, constraints, indexes, views, stored procedures, functions and triggers
• First added in DAC v2 Feature Pack CTP
.bacpac files• Uses JSON format for data
• Much easier than using (and configuring) bcp
• Avoids issues with code pages and precisionNot intended as a backup mechanism
• No transaction log or history
• Not transactionally consistent (where concurrent access is occurring)
DACImportExportCLI.exe –s localhost-d RetailDB -f C:\EXPORT\RetailDB.bacpac
-x -e
DAC Import
Imports schema and data
• Registers Data-Tier Application
Greatly simplifies migrations
• SQL Server -> SQL Azure
DACImportExportCLI.exe –s sdf23sdf.database.windows.net-d RetailDB-f C:\EXPORT\RetailDB.bacpac-i-u Username-p Password
31
SQL Azure Integration
BACPAC can also be used in SQL Azure portal
• Databases export .bacpac to Windows Azure storage
• Create one or more databases based on importing .bacpac from storage
Extract/Deploy Data-Tier Applications to/from local filesystem
• Use SSMS directly connected to SQL Azure
Call To Action!
Consider using DAC Fx on your next project
• Focus on the data model, not on the schema
changes
Simplify your application deployment
• Move on from error-prone scripts
• Distribute .dacpac or .bacpac files with your
application
32
33
Spatial
או מי צריך
את זה
בכלל
?Spatial-מי משתמש ב
34
!כולנו
תוכן
קצת על רפאל ועליי•
?מה זה מערכת מידע גיאוגרפית•
אתגרי מערכת מידע גיאוגרפית–
סוגי מידע•
גיאומטרי–
גיאוגרפי–
אינדקסים•
•Tessellation
•Spatial Aggregations
SQL 2012-חידושים ושיפורים ב•
35
קצת על רפאל
מייצרת ומספקת מגוון מערכות לחימה מתקדמות אשר , מפתחת•
:תורמות למערכת הביטחון יכולות
בים–
באוויר–
ביבשה–
₪מיליארד 1.8למעלה מ –2010רווחים בשנת •
עובדים 5000-למעלה מ•
עליי קצת
בוגר החוג למערכות מידע באוניברסיטת חיפה •
•DBA שנים 6.5-תשתיתי כ:
–MS SQL 2000-2012
–Oracle 9i-11g
–SQL Anywhere 10
–Sybase
36
תחומי אחריות
.שרתים במערכות מרכזיות 100-תחזוקה שוטפת של למעלה מ•
:הדרכה והטמעה של מגוון שירותים וכלים, פיתוח•
–Reporting Services
–Integration Services
–Spatial
–PowerShell
–Mirroring, Replication ועוד...
שאילתות וכיוונוןשיפור ביצועים •
ל"ברפא פרוייקטיםייעוץ וליווי •
אבטחת מידע בבסיסי נתונים•
אז מה זה בעצם מערכת מידע
?גיאוגרפית
הן מערכות מידע המטפלות בהיבטים המרחביים ) GIS(מערכות מידע גיאוגרפיות •
ג תשמור ברשומותיה את כתובת העסק והפוליגון "ממ, למשל. של המידע
.המרחבי התוחם אותו באופן שיאפשר את ניצול המידע הזה
:שונות כגון ישוייותג יודעת לענות על שאלות בנוגעות ליחס המיקומים בין "ממ•
?Yלכתובת Xמה המרחק בין כתובת –
?)פוליגון( Yנמצאת בשכונה Xהאם הכתובת –
?נחתכים Yוכביש Xהאם כביש –
מסויימתמשכונה /הנכנסים או יוצאים אל) קווים(הבא לי את כל הכבישים –
)פוליגון(
מספר דיירים , למשל שווי נכס. ג שומרת גם נתונים נוספים ורגילים"ממ, בנוסף•
.'וכו
37
המידע הגאוגרפיתאתגרי מערכת
מורכבות אלגוריתמית•
יש צורך באלגוריתמים מתוחכמים על מנת לענות ביעילות על –
שאילתות גיאוגרפיות
נפח בסיסי הנתונים•
, כבישים(מספר הרשומות . יש צורך בשמירת מידע בהיקף רב–
של העיר ניו יורק מגיע למיליוני רשומות) 'וכוקווי חשמל , צינורות
בעיות תצוגה•
מפורטת , )אמינות המידע(איך להציג את הנתונים בצורה נכונה –)גיאודיזה(ונעימה לעין ללא עיוותים ) חדות(
DB-סוגי המידע המרחבי הנשמרים ב
:סוגי מידע מרחבי 2נשמרים SQL-ב•
גיאומטרי•
מוכר לכולנו משיעורי ההנדסה ביסודי–
גובה, רוחב,לציון אורך x,y,zמערכת צירים –
י קווים ומצולעים"מוגדרת ע–
גיאוגרפי•
'וכומפות באינטרנט , מוכר בעיקר מאפליקציות ניווט–
)WGS84-לרוב משתמשים ב(מערכת ייחוס גיאודזית –
מסויימתכל משבצת מייצגת תא שטח ברזולוציה –
38
מידע גיאומטרי
:מייצג אובייקטים גיאומטריים שונים כגון)Point(נקודה –
מורכבים יותר אובקייטיםליצירת ) הבינייןאבן (משמשת כיחידה הבסיסית ביותר •
מדוייקמייצגת מיקום •
לציון M-לציון גובה ו zכאשר ניתן להוסיף גם x,yציון במערכת צירים נקודוי "מוגדרת ע•
POINT(10 10) / POINT(10 10: למשל. יחידת מידה 10 1)
'וכוהיקף , שטח, אין לה מאפיינים כגון אורך•
)Linestring(קו –
LINESTRING(0 0, 10 10)מציין נתיב בין מספר נקודות •
נחשב כצורה פשוטה כאשר הוא לא חותך את עצמו•
כאשר הוא יוצר צורה סגורה) מעגל(נחשב כטבעת •
)אפילו כאשר מוגדר כמעגלי(יש לו אורך אבל אין לו שטח , מימדיתתמיד נחשב כצורה חד •
)Polygon(פוליגון
מימדיתדו , צורה סגורה•
בעלת שטח ואורך•
בתוכה" חורים"יכולה להכיל •
)Collection(אוסף –
מקביל למערך ברוב שפות התכנות המקובלות•
קווים או פוליגונים, מכיל אוסף של נקודות•
GeomCollectionהאוסף הגנרי ביותר נקרא •
MultiPoints,MultiPolygon,MultiLineStringממנו נגזרים •
39
עבודה עם מידע גיאומטרי
:גיאומטריים יש להשתמש בפונקציות שונות כגון אובקייטיםעל מנת לעבוד עם •
•STGeomFromText–הפיכת מחרוזת לאובייקט גיאומטרי תקין
SET @g = Geometry::STGeomFromText('LINESTRING(0 0, 10 10, 21 2)',0)
•STEnvelope–יצירת פוליגון מרובע מסביב לצורה נתונה
•STConvexHull–יצירת פוליגון המקיף את קווי המתאר של צורה נתונה
•STDifference()–י צורה אחרת"מחזירה את השטח השונה של צורה הנחתכת ע
•STIntersection()– צורות נחתכות 2מחזירה את השטח החופף בלבד בין
•STUnion()– צורות נחתכות 2מחזירה את השטח החופף של
דוגמאות
40
מידע גיאוגרפי
:מייצג אובייקטים גיאוגרפיים במערכת ייחוס
latitude-ו longitude-נקודה נשמרת כ•
יש צורך במערכת ייחוס , מכיוון שכדור הארץ אינו עגול•
שלנו אל הקורדינאטותאשר מקרבת את מערכת ) דאטום(
סביב כדור " גובה פני הים"המשטח המייצג את ( הגיאואיד מכיון WGS84הינו GPSהנפוץ במערכות הדאטום. הארץ
ברוב כדור הארץ הגיאואידשהוא קרוב יחסית למשטח
מידע גיאוגרפי
הנכון בדאטוםחשוב להקפיד על שימוש
!!עבור המערכת שלנו:לא נכון גורם לטעויות חישוביות בדאטוםשימוש •
האיים הלא נכונים 2נבנה גשר בין 60-בשנות ה–
בהוואי
המפציצים האמריקאים פגעו , במלחמת המפרץ–
מטרים מהמטרה 750בקביעות בסטייה של
41
Spatial indexes
:נסתכל על הדוגמא הבאה•
נשמרים בטבלה לכל , במערכת ציונים באוניברסיטה–
.סטודנט פרטיו האישיים וציונו הממוצע
אם נרצה לשלוף רק , רשומות 20,000בהנחה שיש –
השליפה תיקח זמן רב , ומעלה 90את אלו עם ממוצע
)יחסית(
נגדיר אינדקס על שדה הציון , לצורך שיפור השליפה–).O(n)�O(logn)(הממוצע ונשפר את יעילות הריצה
בעוד ששאילתות כלליות מבצעות השוואות על פי •השאילתות כוללות ג"בממ) =<>(יחס סדר
.אופרטורים מרחביים
נרצה בנוסף לענות גם על שאילתות כגון ג"בממ•אליעזר קריתמי הסטודנטים המתגוררים בשכונת "
"?בחיפה
מעבר על -אפשר לפתור את הבעיה ללא אינדקס•כל הטבלה ולכל רשומה לבדוק האם היא בתוך
אליעזר או לא קריתהפוליגון של
42
ל נשתמש "כדי להתגבר על חוסר היעילות הנ•
קיימים מספר סוגי . באינדקסים גיאוגרפיים
.אינדקסים גיאוגרפיים ולכל אחד יתרונות וחסרונות
Fixed quadtreeהאינדקס הנפוץ והפשוט מכונה •
index
בשיטה זו מחלקים את העולם לריבועים בגודל •
ממספרים את הריבועים ולכל צורה במרחב , קבוע
.ים בו היא נמצאת/שומרים את הריבוע
:כעת החיפוש יבוצע בשני שלבים•
חיפוש גס–
תחילה נחשב את כל הריבועים התוחמים את שכונת קריית •
אליעזר
נשלוף את כל הרשומות אשר מספר האריח שלהן נמצא •
בשלב זה כבר פסלנו חלק גדול מהרשומות. ברשימה
חיפוש עדין–
עבור הרשומות שנותרו נבדוק האם הן בתוך הפוליגון •
י כך נסנן רשומות מרחובות סמוכים "ע. המגדיר את השכונה
שלא נכללות בשכונה המבוקשת
43
.B-trees-י שימוש ב"האינדקסים נשמרים ע SQL-ב•
מימדי של האינדקס -לצורך שיטוח המידע הדו• four-level grid -משתמש ב SQL-ה, B-לתוך עצי ה
hierarchy
כל שכבה נוספת מפרידה את השכבה שמעליה ומציגה •
אותה בפירוט נוסף
44
צפיפות האינדקס
רמות צפיפות 3לכל שכבה באינדקס ניתן להגדיר •
:יצירת האינדקס מתבצעת באופן הבא•• CREATE SPATIAL INDEX SIndx_SpatialTable_geography_col3 ON
SpatialTable2(object) WITH ( GRIDS = ( LEVEL_3 = HIGH, LEVEL_2 = HIGH ) );
Number of cellsGrid configuration Level
164x4Low
648x8Medium
25616x16High
45
Tessellation
האינדקס קורא את , לאחר בניית הרשת השטוחה•
" פסיפוס"העמודה הגיאוגרפית שורה אחר שורה ומבצע
.של הנתונים השייכים לאותה משבצת
שכבה אחת בכל , קורה בכל ארבע השכבות" פסיפוס"ה•
.פעם
שבהם יש touched cellsבתהליך מוכנסים לאינדקס •
.לאובייקט המאונדקס באותו רגע" נוגעים"אובייקטים ש
Tessellation Rules
משתמשים , על מנת להגביל את המידע המוכנס לאינדקס•. tessellation rulesב
•The covering rule
אם האובייקט מכסה תא לגמרי הוא נחשב כתא מכוסה–
"פסיפוס"תא מכוסה נספר אבל לא נחשב בתהליך ה–
השכבות 4החוק הזה תקף בכל –
מפשט את התהליך וחוסך בגודל האינדקס–
46
•The cells-per-object rule
החוק שולט בכמות המידע הנשמרת עבור כל אובייקט
י הגבלה של מספר התאים הנספרים "ע, בשכבות הנמוכות
)למעט בשכבה הראשונה(עבור כל אובייקט
47
•The deepest-cell rule
י שמירה של "מאנדקס בצורה הטובה ביותר את האובייקט ע
.המידע בשכבה התחתונה ביותר
התאים בשכבות העליונות לא נכללים בספירת כמות התאים
לאובייקט ולכן לא נשמרים באינדקס
48
Spatial Aggregation
הצגת מאוחדת של שכבות מידע שונות•• SELECT Geography::UnionAggregate(geog) FROM Counties WHERE name = 'Washington';
• SELECT Geography::EnvelopeAggregate(geog) FROM Counties WHERE name = Washington';
•
• SELECT Geography::CollectionAggregate(geog) FROM Counties WHERE name = 'Washington';
• SELECT Geography::ConvexHullAggregate(geog) FROM Counties WHERE name = 'Washington';
49
SQL 2012-שיפורים וחידושים ב
:Circular Arc-תמיכה ב•
– CircularString
– CompoundCurve
– CurvePolygon
כמות מידע מצומצמת באופן משמעותי הנדרשת על –
.מנת לשמור מידע על קווים מעוגלים
יכול להשתלב עם מקטעי קווים ישרים–
DECLARE@CircularSegmentGEOGRAPHY=GEOGRAPHY::STGeomFromText('CIRCULARSTRING(0 -30, 0 0, 0 30)',4326);SELECT @CircularSegmentAS Shape;
Full Globe Support
•SQL 2008 היה מוגבל כדור בכל פעם
תמיכה במתודות חדשות•– EnvelopeAngle() method returns 180 for objects larger than a logical
hemisphere and < 90 for smaller objects
– ReorientObject() reverses the ring orientation
DECLARE @Globe GEOGRAPHY=GEOGRAPHY::STGeomFromText('FULLGLOBE',4326);SELECT @Globe.STArea();-- calculate the area of the WGS84 ellipsoid-- Result: 510,065,621,710,996 square meters
50
Spatial Index Enhancements
מהירה יותר 4-5מהירות בנייה פי •
•Auto-grid
GRIDSמחליף את הפרמטר –
רמות 8-משתמש ב–
נותן דיוק רב יותר–
דחיסה של האינדקס•
בשטח האינדקס 40-60%ניתן לחסוך –
•Hints חדשים לשיפור ביצועים
?מה למדנו
מה זו מערכת מידע גיאוגרפית •
האתגרים בבניית מערכת כזו•
)גיאוגרפי/גיאומטרי(הבדל בין סוגי המידע הנשמרים •
כיצד בנויים ואיך עובדים -אינדקסים גיאוגרפיים •
איחוד שכבות מידע גיאוגרפיות•
2012-שיפורים וחידושים ב•
51
52
Boosting
performance
with
Columnstore
Indexes
Michael
Zilberstein
DBArt Ltd
DEMO
53
History
• Column-oriented databases:
– Sybase IQ
– Vertica
– Aster Data
– Greenplum
– …
• Excel PowerPivot.
• VertiPaq.
• xVelocity Columnstore index.
C1 C2 C3 C5 C6C4
Uses VertiPaq
compression
54
Reduced IO
C1
C2
C4 C5 C6
C3
SELECT C2, SUM (C3) …
Fetches only needed columns from disk
Columns are compressed
Less IO
Better buffer hit rates
New query execution technology
• Batch mode execution of some operations
– processes rows in batches
– groups of batch operations in query plan
• Better parallelism, better algorithms
55
Dictionary-based compression
Year of
Birth
1996
1975
1975
1948
1932
…
Year of
Birth
Code
1996 1
1975 15
1948 50
1932 58
… 60
Year of
Birth
Code
1
15
15
50
58
60
Internal Dictionary
Compressed Fact
On-the-fly build dictionary with all distinct value.
Substitute non-selective values with ID.
Index in our example – 6 bits per row.
Segments
Column segment contains values from one column for a set of about 1M rows
Column segments are compressed
Each column segment stored in separate LOB
Column segment is unit of transfer from disk
C1 C2 C3 C5 C6C4
Set of about
1M rows
Column
Segment
56
Data Dictionary Views
New execution plan elements
57
Best practices / worst practices
• Best practices:
– Put columnstore indexes on large tables only.
– Include every column of the table in the columnstore index.
– Structure your queries as star joins with grouping and aggregation as much as possible.
• Worst practices:
– Avoid JOIN and/or filter on string columns in the table with columnstore index.
– Avoid OUTER JOIN, UNION ALL, IN/NOT IN.
– Avoid JOIN between 2 Fact tables.
Datatype Limitations
• Decimal > 18 digits
• (Var)Binary
• BLOB
• (N)Varchar(max)
• Uniqueidentifier
• Date/Time types > 8 bytes (Datetime2 etc)
• CLR
58
Issues and Workarounds: good, bad and ugly
• Outer Joins
• NOT IN
• Scalar Aggregates
• Multiple DISTINCT
• UNION ALL
• IN and EXISTS
Data loading and columnstore index
• Columnstore index makes table read-only.
DEMO
59
Data loading and columnstore index
• 2 ways to load data:
– Partition switching
– Disable/drop index -> load data ->
create/rebuild index.
References
• http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/DBI312
• http://social.technet.microsoft.com/wiki/contents/articles/4995.sql-server-columnstore-performance-tuning.aspx
60