r/SQLServer • • Nov 17 '16

[AMA] Microsoft SQL Server - 11/18

Hi Everyone!  

We're from the Microsoft SQL Server Engineering Team and we want you to ask us anything!  

We're posting this a bit early so you can start asking questions - feel free to start asking and we'll start answering Friday 11/18 at 9:30 PDT until 14:00 PDT. We'll have members from the Engineering teams participating in the AMA. This includes folks working on

  • SQL Server Features such as Columnstore, In-Memory OLTP, Row-Level Security, PolyBase, Stretch, or any of the features listed here.

  • Database Tools for Microsoft SQL Server and Azure SQL Database (SSMS, SSDT, SSRS, SSIS, SSAS, SSMA, SQLPS, CLI Tools)

  • Azure Portal for Azure SQL DB, Azure Elastic Database Pools or Azure Virtual Machines with SQL Server

  • R Services for predictive analytics, machine learning, and using scalable R packages with SQL Server technologies

  • Developing with SQL Server using the language of your choice (Examples. Node, Python, Java, etc.) or connecting your app to SQL Server using our drivers (ODBC, JDBC and open source drivers)

  • Migrating or Building Apps and Solutions with SQL Server and the resources we have available to help you get the most out of SQL Server.

  • [SQL Server on Linux] (https://www.microsoft.com/en-us/sql-server/sql-server-vnext-including-Linux)

  • [SQL Server 2016 Service Pack 1] (https://blogs.technet.microsoft.com/dataplatforminsider/2016/11/16/sql-server-2016-service-pack-1-generally-available/)

Here are some question ideas:

  • What’s new in SQL Server Service Pack 1 and SQL Server on Linux?

  • How does your team take the feedback from the community?

  • What tools would I use to migrate my database to SQL Server?

  • What’s a cool trick you don’t think most customers know about?

You can ask us anything about our public products or about the team. If there's a topic that's not listed above, ask it anyways! We'll do our best to answer it. We cannot comment on unreleased features and future plans, though :) Tweet at us with #SQLServer and follow @SQLServer to keep up to speed with what the SQL team is working on. After this AMA, you can also post questions here in reddit or tweet at us any time.

    Update@9:50 PST Hey Everyone! We are starting to answer the questions! Thanks for all the awesome questions so far. keep them coming! :)

    Update@2:15 PST Hey Everyone! Wow. Over 100 questions. Thanks for joining us today and participating in our SQL Server AMA! We're currently wrapping up the AMA, but we will do our best to answer the remaining questions. Going forward, the SQL Server Team will be more active on this subreddit. We're particularly excited to hear what you have to say about SQL Server v.Next!  

Also, tell us what you thought about this AMA Event by taking our survey: https://survey.microsoft.com/211438

67 Upvotes

386 comments sorted by

View all comments

Show parent comments

5

u/sunila-msft Nov 18 '16

Great question. Ideally, the escalation should be done based on some % of the total number of rows in a table. Unfortunately, there is no easy way to figure out what is the right % for escalation as it depends so much on the workload. For this reason, we provided an explicit option to enable/disable lock escalation at table and partition level starting with SQL Server 2008.

1

u/sbrick89 Nov 18 '16

just to reiterate the point, I was getting asked by a CIO about this very question about 2 hours ago. The impression from SQL prod team is that it's a minor nuisance; the impression from ANYONE in the SharePoint world (normal users, power users, administrators, developers) is that it's one of the top 10 questions/problems. And all we can do is point and say "it's not something SharePoint can control, it's a SQL issue, and they don't care"

1

u/sunila-msft Nov 19 '16

Sorry, not trivializing the question...Can you please clarify (a) are there tables on which you never want lock escalation? (b) there are table where you want lock escalation but after much higher number of rows have been locked? if yes, can you please provide some details? (c) are these rows being locked in the same SQL Statement?

2

u/sbrick89 Nov 19 '16

So a touch of (necessary) background...

  • SharePoint is a CMS that defines content as basically anything... files, lists, notes, whatever... in some ways it provides similar functionality to Access against SQL, in that it provides a very easy to use front-end to customized / used defined structures (tables)

  • To provide hierarchy, SharePoint sites can have subsites (to infinium, or until the URL length breaks something)... each site can have whatever lists and libraries it wants

  • many versions ago, a URL was mapped 1:1 to a database... at some point they decided to create "site collections" as a way to manage database size by splitting the content into chunks... but site collections tend to be rather large chunks (entire departments), if they're even used (many installations still only use one site collection for everything in the URL).

  • Within each database, ALL of the "record" data (basically everything except the file blobs) are in a SINGLE table. To address the flexibility of content types, the table started out as "pretty wide" (like int1..int20 + varchar1..varchar50 + bit1..bit25 + etc)

  • at the time, one of the biggest performance penalties occurred if your list had more columns of a single type than the table had defined... SP had anticipated this, by joining the table onto itself as "row 2"... but the join complexity was a huge performance penalty.

  • In SP2010 they addressed the above issue by using sparse columns to make it "holy crap that's wide" (like like 100 cols of each data type).

now here's the issue... SharePoint is more or less assumed to be able to handle anything without issue... in many cases, it's recommended over file shares... it's used to build custom apps (mostly basic request / ticket type of systems, but i've occasionally seen stupid requests like using it to build core LOB systems with line-item-product level of detail and record volume)... and in general, computers should be able to handle at least like 25k of records without a sweat, usually up to 500k... at which point hardware and indexing might start to have significance... I say this because users will build systems without worrying upfront about "current/open" records vs "archive" records... a ticket system might get 1k requests a month, and they figure that a simple view (SP views are analogous to SQL views) to show me "what's open" should be sufficient for most cases, and if they need to load all records over the past few years, they don't mind it being a tad slow... so they design all the records to remain in a single list (table).

thing is, SharePoint, knowing SQL's 5k lock escalation, won't (by default) let a list view more than 5k rows at a time... because if you were to do so, the query would pull a TABLE lock on the the "AllListItems" table in the database, which would lock EVERYTHING in the entire database (which is often analogous to URL).

So, users are told "oh, you're trying to use more than 5k records at a time, and you can't"... "why so few? why can't it be 25k or more?"... "ask the SQL team". This conversation occurs at least once in every application of SharePoint, because SP is so damn easy to use and load with info... and then people feel burned by trying to really use as much as possible, only to find out that they're having their hands slapped at what is perceived to be a VERY low threshold.

So that's the issue in a nutshell... Sure, you could point to the SharePoint architecture, but it works relatively well in most use cases compared to some of the alternatives (DotNetNuke is more of a front-end to modifying SQL tables directly, OnBase uses a table for each field of data).


As far as resolutions / recommendations

Given the architecture of SharePoint, being able to customized the threshold would be great (and in fact, SP does let admins override the 5k - I've got clients that set it up to 25k/50k - but it's a superficial setting since it is changed in response to need, which means that users are trying to run queries against >5k rows, which means that admins know that it's causing TABLOCKs)... personally I'd love it if the SP setting could actually adjust SQL directly... SP adjusts it on a per URL basis, which has a 1:N mapping to databases... so i'm unsure whether it'd make more sense to have the threshold at the DB level or at the instance level... but letting the admins control it would (I think) be ideal.

As an alternative, especially given the types of storage media these days, a much higher limit (bump it up 10x to 50k) would be a decent middle ground... probably applicable in general given the growth of data since the decision to use 5k was made.

One could argue the idea of making it based on table size (testing would probably give the best ratio, but i'd guess 1-5%)... but I suspect that the overhead of lookup might be significant.

Perhaps some simple setting that's updated with stats / maint plan... just set the size in a property somewhere, then have stats auto-update it on a nightly basis or something... which would in theory provide extensibility around the algorithm, such that some applications / admins / developers might want it higher or lower than OOTB.


some additional reading (I was unable to look for the specific article I wanted, since the 5k limit is overwhelmingly discussed to death by everyone that's ever worked with SP)

1

u/[deleted] Nov 18 '16

Ok, so how does this decision compare against Oracles lack of escalation?

1

u/sunila-msft Nov 19 '16

SQL provides an explicit DDL to disable lock escalation at table level. so you can pretty much get the same behavior. Does this answer your question?

1

u/[deleted] Nov 19 '16

Not something we can use with SharePoint, but yeah.