Friday, May 29, 2015

What is different in first install of SQL 2016 CTP2



The two most visible changes to installation of SQL server are:
1. The installer now recognizes the number of cores in your serer and creates tempdb with the 
    number of cores if the cores are less than 8 or 8 if the number of cores is more than 8. At last 
   Microsoft addressed what SQL Server User community and professionals were recommending. 
  See image below. In my case, my server has four cores and it recognizes and create temp files.


2. Another exciting feature that was brought into main stream SQL server is Polybase. Polybase is a  
    T-SQL front end that allows users to query non-relational data.  Polybase was used to query an 
    external Hadoop cluster connected to APS. This is good news for queries non-relational data from 
    within SQL server engine. I personally cannot wait to play with it and finally if good may use it 
    for   real.  To use this feature you need to install Oracle JRE Update 51 or higher. Otherwise you 
    will get the following error and will not progress with installation.
 


Thursday, May 28, 2015

Changes to in-memory OLTP in SQL 2016

What are the changes?  In this post, I will be summarizing the changes to in-memory OLTP component of the product.  This feature was first introduced in SQL server 2014. We all know the first release will have limitations. From my past experience with SQL server, new features tend to have limitations.  So, what are the improvements?

Schema and data changes:  The limitation of altering a table is now removed. You should be able to use alter table on memory-optimized tables to drop, add and alter columns.  You should also be able to drop or rebuild indexes.

There is a bit of improvement on parallel plans.  Operations that use hash indexes can now be performed in parallel unlike SQL 2014 were the optimizer never creates parallel plan for any operation

 SQL 2016 now supports TDE for memory optimized data filegroup.

Support for multiple log reader threads to read transactions that affects memory-optimized tables from transaction log. One more bottleneck removed and this operation is now faster than it was in 2014. SQL server 2016 now allows multiple threads for both recovery and checkpoint, read and apply logged transactions which can result in the ability to scale memory optimized operations.

Some improvements on filestream processing.  The removal of dependency on windows files stream processing.

Garbage collection in memory:  In SQL 2014 garbage collection was too slow. In some cases, even when memory optimized table was dropped the memory wasn’t immediately available to be used due to slower  garbage collection rate as opposed to  row version changes. The algorithms of collecting garbage are now improved and hope this is the case.

In SQL 2016, all data whether it from disk or memory optimized tables will be visible immediately on AlwaysOn secondary replica. So less work for developers.

The original recommendation of 250GB of memory for memory-optimized tables are now lifted to 2TB

The requirement for columns of Memory-optimized tables that uses an index to be BIN2 collation is also removed.

Support for more DML operations such as select distinct, different type of joins (such as Left and right outer join), union, union all, nested stored procedure calls, subqueries and OR and not are now added.

Thursday, May 14, 2015

SQL Server 2016 public preview coming soon

Highlights of the upcoming public preview of SQL server 2016 features:

  • Dynamic Data masking
  • Row-level Security 
  • Three synchronous replicas on AlwaysOn
  • Native JSON support (Now supporting the world of Big Data)
  • More improvements on hybrid backups (pushing more of cloud)
  • Built-in advanced analytic, polybase and mobile BI
  • Real-time Operational Analytics & In-Memory OLTP
  • Stretch database. New technology that allows you to dynamically stretch your warm and cold transnational data to Microsoft Azure
  • Always  encrypted : as per T.K. Ranga Rengarajan blog "Always Encrypted, based on technology from Microsoft Research, protects data at rest and in motion. With Always Encrypted, SQL Server can perform operations on encrypted data and best of all, the encryption key resides with the application in the customers trusted environment. Encryption and decryption of data happens transparently inside the application which minimizes the changes that have to be made to existing applications"



Tuesday, May 12, 2015

Get SQL Loginame when you know the password




Did you ever found yourself in a situation where a user knows their sql login password but not username? Well, I did.  I want to share this SQL statement that helps you to retrieve the name of sql login if you know the password.


--will return any name with the same password as in the Check text.
SELECT name FROM sys.sql_logins
WHERE PWDCOMPARE('', password_hash) = 1

Friday, March 21, 2014

Updatable columnstore clustered indexes, is it new feature for SQL 2014 ?

The new release of SQL server 2014 boosts on improvement of columstore index. As we all know, SQL Server 2012 introduced columnstore indexes. I haven't seen it widely used in data warehouse implementation due to the fact that you can not update. If you want to reload the data you have to drop and re-create the index. This might be possible if you are working with rows less than 1 billion. But if your table is more than 1 billion it is very difficult to use. So, the new release not only made the column store index updatable but also can be clustered index. It is all good news but is this a new feature ? I would say for normal version of SQL server it can be seen as new. But, Microsoft released this feature with SQL Server 2012 Parallel data warehouse. What they did is they moved the technology to new version of SQL server. To claim this is a new technology in my opinion is wrong and misleading. The technology was there in their special version of SQL server 2012 (for Parallel data warehouse).

Wednesday, March 19, 2014

Microsoft's SQL Server 2014 release code: First look

It come so fast after the release of 2012 but the new SQL server has arrived. Read more SQL server 2012 realease

Friday, January 17, 2014

SQL Server 2014 release date?

The exact date of release is still not set but insider from Microsoft thinks it will be released in the first half of 2014. or 3rd Quarter of 2014. Played with CP2 and looks pretty good. Waiting to play with when it is released. As usual, I will wait till SP1 is released before moving any production probably early next year

Wednesday, August 28, 2013

SQL 2014 new feature (Updatable columnstore)

One of the new features introduced on SQL server 2012 was a memory optimized columnstore index. This feature not only reduces the amount of storage but also the speed of the query. During my test, I found that the speed of a query performance before and after columnstore index was in magnitude of 15 times faster. Wow, that was very impressive. As being new feature it have its own drawbacks. You are not able to update the data, hum. The workaround was very cumbersome and not suitable for some of data warehouse solutions. If you want to update data you need to drop the columnstore index update the data and recreate it.

If you have already upgraded to 2012 to make use of the columnstore index then you may have to upgrade to the new SQL server 2014. SQL 2014 doesn’t require the workaround of updating data. The new release enhanced the columnstore to be a pure columnar store. Bang on!!

Data warehouse is much happier place to be with SQL 2014. Not only you will be able to save space but also increase query performance.

Thursday, August 22, 2013

When is SQL server installed

I have been asked may times how to find when a SQL server is installed. Mostly I told them to find the installation log. But, what I didn't realized is that you can find out by querying sys.syslogin database.To my surprise, quiet an easy statement. You can use
SELECT  createdate as Sql_Server_Install_Date, *
FROM    sys.syslogins
where   sid = 0x010100000000000512000000 
or
SELECT  createdate as Sql_Server_Install_Date
FROM    sys.syslogins
where  loginname = 'NT AUTHORITY\SYSTEM'
One of the above will do  as long as default language is English

Flushing the cache for one database

DECLARE @DBID int
 SET @DBID = ( SELECT dbid FROM master.dbo.sysdatabases WHERE name = 'db')
--Flush procedure on the db
DBCC FLUSHPROCINDB (@intDBID)

Friday, May 17, 2013

Execution plan puzzle


I recently come accross a query that used to run fine on production server but suddenly
Execution plans can be affected by different statistics, parallelism due to number of processors, the amount of available RAM in the server, different service packs, different server configuration settings, and the current load on the server. I imagine one or more of these are causing what you are seeing.

Friday, May 11, 2012

SQL server system table corruption

Recently I came across a sage database that has been corrupted. When running DBCC CHECKDB command I was getting the following errors:

There are 226 rows in 1 pages for object "sys.sysprivs".
DBCC results for 'sys.sysschobjs'.
Msg 2511, Level 16, State 1, Line 1
Table error: Object ID 34, index ID 2, partition ID 562949955649536, alloc unit ID 562949955649536 (type In-row data). Keys out of order on page (1:47), slots 66 and 67.
Msg 2511, Level 16, State 1, Line 1
Table error: Object ID 34, index ID 2, partition ID 562949955649536, alloc unit ID 562949955649536 (type In-row data). Keys out of order on page (1:47), slots 72 and 73.
Msg 2511, Level 16, State 1, Line 1
Table error: Object ID 34, index ID 2, partition ID 562949955649536, alloc unit ID 562949955649536 (type In-row data). Keys out of order on page (1:47), slots 93 and 94.
There are 4147 rows in 93 pages for object "sys.sysschobjs".
CHECKDB found 0 allocation errors and 3 consistency errors in table 'sys.sysschobjs' (object ID 34).

Normally the re-indexing should have fixed this type of issue when the base table is user table but it didn't. To fix the issue I have to perform the following commands



use DatabaseName
 go
ALTER DATABASE DatabaseName  SET SINGLE_USER
go
DBCC CHECKDB('DatabaseName', REPAIR_REBUILD)
 go
The outcome from the above command was

Repair: The Nonclustered index successfully rebuilt for the object "sys.sysschobjs, nc1" in database "FCE_Sage".
Msg 8945, Level 16, State 1, Line 1
Table error: Object ID 34, index ID 2 will be rebuilt.
        The error has been repaired.
Msg 2511, Level 16, State 1, Line 1
Table error: Object ID 34, index ID 2, partition ID 562949955649536, alloc unit ID 562949955649536 (type In-row data). Keys out of order on page (1:47), slots 66 and 67.
        The error has been repaired.
Msg 2511, Level 16, State 1, Line 1
Table error: Object ID 34, index ID 2, partition ID 562949955649536, alloc unit ID 562949955649536 (type In-row data). Keys out of order on page (1:47), slots 72 and 73.
        The error has been repaired.
Msg 2511, Level 16, State 1, Line 1
Table error: Object ID 34, index ID 2, partition ID 562949955649536, alloc unit ID 562949955649536 (type In-row data). Keys out of order on page (1:47), slots 93 and 94.
        The error has been repaired..