Friday Reading 2017-04-28

Nearly May! Although it’s been snowing this week in Dublin so summer still appears to be a while off…

Community driven Enhancements in SQL Server 2017
The MS Tiger Team list the new features in SQL 2017 that have been built based on feedback from the community

SQL Server 2017 – Adaptive Query Processing
Joe Sack takes us through a new (and really cool imho) feature in SQL 2017

SQL Community Scripts
Shane O’Neill has put together a handy list of all the scripts available out there

Why Did Your Availability Group Creation Fail?
Anthony Nocentino takes us through an error that he encountered when setting up an Availability Group (I like posts about real world issues and resolutions)

Have a good weekend!

Pausing index rebuilds in SQL Server 2017

Last week Microsoft confirmed that the name of SQL vNext will indeed be SQL Server 2017. I was looking through the documentation for more info on Adaptive Query Processing as I wanted to write a post on adaptive joins but then I saw: –

To see the new Adaptive Join operator in Graphical Showplan, a new version of SQL Server Management Studio is required and will be released shortly.

Source

Ok, I’ll wait! So I went back to the list of new features in SQL 2017 and something else caught my eye. The ability to pause and then resume online index rebuilds.

Sounds pretty cool, let’s see it in action. Here’s the setup: –

(SQL Server 2017 can be downloaded from here btw)

USE [master];
GO

CREATE DATABASE [Test]
GO

ALTER DATABASE [Test] SET COMPATIBILITY_LEVEL = 140
GO

That’s the database created and put into the correct compatibility level (just to be sure). Now let’s create a table to test with: –

USE [Test];
GO

CREATE TABLE [TestTable]
(PKID INT IDENTITY(1,1) CONSTRAINT PK_Test PRIMARY KEY CLUSTERED,
 ColA VARCHAR(10),
 ColB VARCHAR(10),
 ColC VARCHAR(10),
 ColD DATETIME)


SET NOCOUNT ON;
INSERT INTO [TestTable]
(ColA,ColB,ColC,ColD)
VALUES
(REPLICATE('A',10),REPLICATE('B',10),REPLICATE('C',10),GETUTCDATE())
GO 100000

OK, now let’s rebuild the clustered index that we’ve created on the table: –

ALTER INDEX [PK_Test] ON [TestTable] REBUILD WITH (ONLINE=ON,RESUMABLE=ON);
GO

N.B. – notice the new option RESUMABLE=ON

Whilst that’s running, open a new connection and run: –

USE [Test];
GO

ALTER INDEX [PK_Test] ON [TestTable] PAUSE;
GO

The session that running the rebuild should now have stopped with the rather disconcerting error: –

Looks pretty worrying imho! But not to stress, jump back to your other connection and run: –

ALTER INDEX [PK_Test] ON [TestTable] RESUME;
GO

Hmm, but how do I tell that this has worked? Well, if you have sp_whoisactive on your instance you can verify that the query is re-running: –

Pretty cool, huh? Full information on this can be found here: – https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-index-transact-sql

I think this is very useful but we do need to be careful. The documentation says that pausing an online index rebuild for a long time may affect query performance and disk utilisation. This is due to the newly rebuild index being created side-by-side to the original one so we’ll need to watch out for that.

Thanks for reading!

Monday Coffee 2017-04-24

Back after a couple of busy weeks, kinda looking forward to getting back into the old work routine (ah, well maybe 🙂 )

Last week was a big week, I had my first article published on SQLShack.com and there were a couple of small events going on called Docker Con 2017 and Microsoft Data Amp.

Docker announced that all the open-source projects are being consolidated under one name Moby. Not too sure what this means for the future of the project as Docker (the company) now want to focus on Enterprise (paid-for) solutions. Hopefully this is a good thing but time will tell.

The biggest announcement from Microsoft was that we now know that the next version of SQL Server will be called SQL Server 2017. Lots of new features to get stuck into but the one that caught my eye was Adaptive Query Processing.

There’s an excellent video here in which Joe Sack takes us through what AQP is and how it works. I definitely recommend that you give the video a watch.

I jokingly said on twitter that this feature is liable to put me out of a job. Obviously I don’t think that, the way I look at features like these is that they are another tool in the belt of the DBA. It will allow us to be freed up from routine tasks and focus on more in-depth work.

Plus, it’s not going to get things right all the time, is it?

Have a good week!

Thursday Reading 2017-04-13

Morning all, it’s been a busy week so I haven’t had a chance to write a post. Instead I’ve seen some great posts written about SQLBits 2017 so I thought I’d link to three of my favourites:-

Why Volunteer at SQLBits ?
Rob talks about his experiences volunteering at SQLBits and how you can get involved. The photos are hilarious!

Attending SQLBits for the first time
Great video by Adam Sexton of pretty much everything that went on at SQLBits!

State of the SQL Nation and the Microsoft Engineering Model
Victoria Holt talks about the points mentioned at the 15 mins Q & A session with Conor Cunningham and Simon Sabin at SQLBits this year

Have a good weekend!

Monday Coffee 2017-04-10

So SQLBits is over and I have to say that I really enjoyed attending on the Saturday, hopefully next year I’ll be able to go for the whole event.

Highlights for me included chatting to the RedGate people about their new product SQL Clone, attending Denny Cherry’s “What not to do with SQL Server” session and of course, presenting my session.

I’m still pretty new to presenting and SQLBits is a little different to SQL Saturdays! Having a microphone and a light shining on you is a bit distracting at first but I found that 10 minutes into my presentation I didn’t notice anymore.

Overall I thought my session went well, I covered everything that I wanted to and had some time at the end which allowed the attendees to ask a few questions, most of which I managed to answer (reasonably well 🙂 )

One thing I did notice, about half way through my session, was that I was enjoying it. Previously when I’ve spoken I’ve been pretty nervous so have kinda had the mentality of…let’s just get this done…so I hope the fact that I enjoyed it came across.

So all in all, pretty chuffed about how it went and I can’t wait to do more.

Have a good week!