SQL Server 2014 comes with dozens of improvements in various areas. In this presentation we will discuss and see how the new release can make the life of each and every developer easier and what are the top 5 T-SQL enhancements that we can use in our day-to-day work.
9. Data pages are located in,
or read into, the buffer cache
and then modified
2
Modification is recorded
in transaction log on disk3
Later, checkpoint writes
dirty pages to database
4
Buffer Cache
Transaction’s lifecycle
11. Data pages are located in,
or read into, the buffer cache
and then modified
2
Modification is recorded
in transaction log on disk3
Later, checkpoint writes
dirty pages to database
4
Buffer Cache
Transaction’s lifecycle
19. Why is the CE so important?
Why is the CE so important?
20. The CE
has not been
changed since
SQL Server 7.0
…and at the same time
21. Queries with Multiple
Predicates
Queries Joining Multiple
Tables
New Data Not Presented
in the Stats
Almost everywhere…
(this, oh btw, means you have
to test a lot!)
Where to expect changes?
Поздрав и благодарности, че все още сте тук за последната сесия?Уморени ли сте вече много?Нали знаете как се говори само за 1 – 2 неща, които са ключови. Иска ми се да ви разкажа и определено да ви покажа 5 други, които определено могат да ви помогнат в ежедневието ви за това да направите приложенията ви по – добри.
Така казано...
Ценя времето ви и искам да ви кажа, че ако сте дошли за това или Clustered Columnstore индекси – няма да чуете нищо.Както и няма да е вери дийп сесия, защото за всяко от нещата, които ще видите може да се изнесе отделна такава (а и все пак е последна сесия, предпочитам да енджойнете)
Прекалено нови неща, за които още няма почти никаква информация в интернет или поне толкова колкото би ни се искало.
Казвам се Борис Христов и работя като Senior SQL Server DBA за HP
В същото време съм Автор за Pluralsight
SQL Server MVP съм, което означава, че може да ме видите или чуете да говоря доста често както тук, така и на доста събития в цяла европа
Не на последноя място се занимавам и с обчения и със SQL Hangouts
Да се захващаме
Така ще протече като последното е интересно и ще е нестандартно. + НАГРАДИТЕ!
Колко от вас са чували това?Standard Edition на продукта...
Change tracking and change data capture All transactions with change tracking are fully durable. A transaction has the change tracking property if it does any write operations to tables that are enabled for either change tracking or change data capture (CDC).
Crash recovery Consistency is guaranteed, but some changes from delayed durable transactions that have committed may be lost.
Cross-database and DTC If a transaction is cross-database or distributed, if is fully durable, regardless of any database or transaction commit setting.
Always On Availability Groups and MirroringDelayed durable transactions do not guarantee any durability on either the primary or any of the secondaries. In addition, they do not guarantee any knowledge about the transaction at the secondary. After commit, control is returned to the client before any acknowledgement is received from any synchronous secondary.
Failover clustering Some delayed durable transaction writes might be lost.
Transaction Replication Delayed durable transactions do not guarantee their replication. Transactions are only replicated after they have been made durable.
Log shipping Only transactions that have been made durable are included in the log that is shipped.
Log Backup Only transactions that have been made durable are included in the backup.
Всяка една система като SQL Server ни дава възможност да контролираме тези 4.
Atomic – Error handling and how we use it
Consistent – Foreign keys, check constraints, triggers, validation rules.
Isolated – locking, isolation levels
Durable – Кой се грижи за това?
transaction log – rolling back and forward
Нека се фокусираме върху последното. Как „преминава“ една транзакция?
Transaction starts -> data is modified in the memory and changes are constantly (sync) send to the log. Once we commit the change and we have all the log records on the log we return the control.
W-A-L – Write ahead logging механизъмЧУДЕСНО! Какво става ако вие сте написали невероятно приложение, но дисковете ви са бавни (за тлога)?
Ами ... Започвате да виждате, че нещо тези инсърти / ъпдейти и т.н не минават така бързо както ви се иска
When you say to the DBAs it’s slow here is what they see.
Wouldn’t it be interesting if…
60 KB buffer -> flush
Sp_flush_log
Durable transaction – MSDTC or Cross database
THERE IS NO ACID ANYMORE!
Locks are same, just released faster
Ways to flush – sp_flushes, durable transaction or 60KB log buffer full
Колко отвас използват SELECT INTO? Колко от вас са чували, че има подобрения за него в 2014?
Подобрението е доста, доста простичко...
За да можете да извлечете максимума от паралелизма. Пример със ССД-то 7 секунди вместо 18.
How many of you have heard about this improvement? What is – QE assignes costs to each plan and the one with lowest cost is choosen. Those costs are actually how many rows are we going to be proceeded for each operator and that’s the work of the cardinality estimator
Talk about the problem – slow queries in general
Under estimation – disk spills, serial plans, bad indexes chosen or join orders
Over estimation – more memory assigned, parallel plan and not serial
So, what is a cardinality estimator? A cardinality estimator is the component of the query processor whose job is to estimate the number of rows returned by relational operations in a query. This information, along with some other data, is used by the query optimizer to select an efficient execution plan. Cardinality estimation is inherently inexact, as it is a mathematical model which relies on statistical information. It is also based on several assumptions which, although not documented, have been known over the years – some of them include the uniformity, independence, containment and inclusion assumptions. A brief description of these assumptions follows.
Uniformity. Used when the distribution for an attribute is unknown, for example, inside of range rows in a histogram step or when a histogram is not available.
Independence. – сямтаме, че данните в колоните са независими освен ако изрично не е казано, че те са.
Containment. Смятаме че ако нещо се търси значи съществува.
Inclusion. Когато имаме where x = нещо – нещото винаги съществува и стойността му е точно такава, каквато я имаме в хистограмата на статистиките.
Stats: Density – the uniqnes of a column
Histogram – data distribution
А също така е и доста комплексна задача.
Изчисленията, които трябва да прави CE трябва да „правилни“ за почти всички клиенти на Майкрософт...
Statistics on ascending or descending key columns, such as IDENTITY or real-time timestamp columns, might require more frequent statistics updates than the query optimizer performs. Insert operations append new values to ascending or descending columns. The number of rows added might be too small to trigger a statistics update. If statistics are not up-to-date and queries select from the most recently added rows, the current statistics will not have cardinality estimates for these new values. This can result in inaccurate cardinality estimates and slow query performance. For example, a query that selects from the most recent sales order dates will have inaccurate cardinality estimates if the statistics are not updated to include cardinality estimates for the most recent sales order dates.
Trace flags 2389 + 2390
With one predicate – no difference except if there are no outdated statistics. If they are the new will consider the total number of rows and the old will consider the statistics
With more than one – it considers that they are correlated and calculates it in a different way
In Joins – quite better (with column joining). With more than one column – new CE underestimates a lot!
With joins with multiple tables and multiple columns there could be even changes in the execution plans!
For modulo % - very good! X