FAQ for data mining add-ins.
Translate
Wednesday, September 26, 2012
Friday, September 21, 2012
Largest SQL Server Installations in the World
I was watching the 24hrsofPASS yesterday and came across the Kevin Cox presentation on PASS - What are the Largest SQL Server Projects in the World?
Following are the statistics for SQL Server world wide.
Following are most valued SQL Server clients.
Here are some statistics for bwin.
Sunday, September 16, 2012
Internal Version of SQL Server Databases
SQL Server has an internal version for it’s databases which as users you don’t need to know about them. But, in some cases like, attaching databases and restoring them between different version you will end up with error messages indicating these internal version numbers. So you need to know about these version numbers.
Following is the error message I received, trying to attach database which was built in SQL Server 2012 and surprisingly my target server is also SQL Server 2012.
It says my current SQL Server version is 705 while I am trying to attach a database of version 706. But both are SQL Server 2012.
Though both are SQL Server 2012, 705 stand for SQL Server 2012 RC0 while 706 stand for SQL Server 2012 RTM!
Here are the internal versions of different SQL Server versions.
This blog post describes about how to measure the version number and other aspects of it.
Thursday, September 6, 2012
SQLskills training goes online worldwide (and free in September!)
Register for the free training in September at www.sqlskills.com at here.
Sunday, September 2, 2012
Query Plan Mysteries
Found nice article about query plan. In summery, query plan is cached not only with the queries but with the SET options. so if your query got cached with a ANSI_PADDING, CONCAT_NULL_YIELDS_NULL, QUOTED_IDENTIFIER and if you are running a acessing it with different set option that previously cached plan will not be used.
Also, depending on your application, DEFAULT set option will be differed,
Specially ARITHABORT setting is ON for SSMS while for ADO.Net it is OFF!.
Read the article, you will find it interesting.
Thursday, August 30, 2012
Simple Default Option Change in SSIS
Prior to SQL Server 2012, when you are importing data from a flat file source, by default Column names in the first row option is disabled. In SQL Server 2012 this option is by default enable!.
Friday, August 24, 2012
XEvents to Monitor Analysis Services
Extended Events a.k.a. XEvents were introduced in SQL Server 2008 as a light weight monitoring mechanism to support DBA.
In SQL Server 2012 XEvents is expanded to more subsystems such as SSAS, Replication, PDW etc. So with this, you have the light weight monitoring system for SSAS.
SQL Server 2012 release includes new trace events to help users for troubleshooting processing issues. Locks Acquired, Locks Released, and Locks Waiting are new trace events included with this release.
New and Modified DMVs in SQL Server 2012
Few changes have happened to DMVs. If you compare the number of DMVs with SQL Server 2008 R2 SP1 dmvs, there are 33 new DMVs.
New DMVs
In SQL Server 2012, you have 174 DMVs in total compared to 141 you have in SQL Server 2008 R2. Out of these 141 DMVs you have in R2 5 of them added by the SP1. So effectively you have 38 new DMVs in SQL Server 2012.
Let us start with those 5 DMVs.
dm_server_registry
Most of your SQL Server configurations are saved in the windows registry. So in case you want those to be read, you might need to read the registry.
In previous version you have to use xp_reg_read undocumented system stored procedures. Since this is an undocumented, many DBAs do not want to use in production environments.
However, with introduction of the DMV, dm_server_registry, you can simply query it with necessary where clause and you will be able to get the necessary configuration information from the registry.
dm_os_windows_info
How often you need windows information to capture in SQL Server? If so you may need to write powershell scripts. However, with the dm_os_windows_info, you can retrieve the information about Windows version, Service Pack level and Language of your operating system.
Insert Image 5528_09_06.png
dm_server_services
How often you need to check whether the SQL Server agent job is running? If you need to execute a job from application, if SQL Server Agent Job is stopped, it will fail. To do a clean task, it will better to verify whether the SQL Server Agent Job is running and give an appropriate error message so that users are attend to the correct issue.
With dm_server_services DMVs you can verify the all the SQL Server services and the startup type as well. Also, for trouble shooting purposes, you can find the last startup time as well.
dm_server_memory_dumps
This DMV returns a list of memory dump files generated by the SQL Server Database Engine along with creation time and the dump file size.
dm_os_volume_stats
This is a function where you need to provide database id and the file id of which need to check the volume stats.
This DMF will return the size of the volume and remaining space on the volume containing that file, file system type (NTFS or FAT) and few more details.
dm_db_log_space_usage
If you are a DBA, you don’t want your log files to auto grow as it would hamper the transaction performance. So you need to monitor the log file space. Most of the times, DBAs will use SQL Server Agent Alerts.
However problem with alert is that alert is event driven not time driven. In case, there is a long running transaction, log will not be cleared and during this time alerts will be received to the responders. So DBAs prefer to use SQL Server Agent Job so that they can schedule them according to the requirement.
In current version of SQL Server using DBCC SQLPERF you can do this using following script.
DBCC SQLPERF also has new column called Principal File Group Name is added in SQL Server 2012. So in case you need to run above script in SQL Server 2008 R2 or below, you need to comment out that column in the temporary table.
Things are easy in SQL Server 2012 with very simple DMV.
Similarly, you can view the used log space from the Disk Usage report available in the SSMS.
Report also has slight but very important change in SQL Server 2012. Now data label is also included in the report. Earlier, you don’t have the actual value and you need to guess it.
dm_exec_describe_first_result_set
This DMV gets T-SQL statement (this can be a procedure as well) and return the metadata of the first result set.
Similarly dm_exec_describe_first_result_set_for_object DMV will give you the same result but difference is you need to pass object id of the stored procedure or a trigger. If you passed ID of any other object such as a view, table, function, or CLR procedure, an error will be specified in the error columns of the result.
dm_db_database_page_allocations
How many times you used DBCC IND in production environments? DBCC IND and DBCC PAGE are undocumented but still many are using them in production. dm_db_database_page_allocations is replacement to DBCC IND. Dm_db_database_page_allocations which can be used to find allocated pages for the database object. This function takes 5 parameters, DatabaseId, tableID, indexID, partitionID and mode.
We have discussed furthermore new DMVs in Alwayson, Full Text Search, Waits and Contained database section.
Modified DMVs
Following DMVs are changed to increase the better usage.
sys.dm_exec_query_stats
sys.dm_exec_query_stats is often used DMV by joining few other DMVs to analyze badly behaving queries. Four additional columns are added to this DMV and they are,
| total_rows | Total number of rows returned by query. |
| last_rows | Number of the rows return by the last execution of the query. |
| min_rows | Minimum numbers of the rows returned by the query after it is compiled. |
| max_rows | Maximum numbers of the rows returned by the query after it is compiled. |
Following is the query you need to execute to analyze bad performing queries.
We testing for performance, DBAs check for page reads. However, if the page reads are high, it might be a bad query plan or it can be user has request for large data set. With these four columns, you can eliminate that dilemma and decide why you have high page reads.
Following DMVs are changed only by data length.
| DMV | Column Name | Previous Length | Length in SQL Server 20012 |
| entry_data | nvarchar(2048) | nvarchar(3072) | |
| record | nvarchar(2048) | nvarchar(3072) | |
| resource_description | nvarchar(2048) | nvarchar(3072) | |
| map_value | nvarchar(2048) | nvarchar(3072) | |
| description | nvarchar(256) | nvarchar(3072) | |
| description | nvarchar(256) | nvarchar(3072) | |
| description | nvarchar(256) | nvarchar(3072) | |
| event_predicate | nvarchar(2048) | nvarchar(3072) | |
| column_value | nvarchar(2048) | nvarchar(3072) | |
| cacheobjtype | nvarchar(17) | nvarchar(50) |
Saturday, August 18, 2012
Columnstore Index
Traditional indexes are based on rows where data is grouped and stored in row basis and then join all rows to complete the entire index. Columnstore indexes store data for columns and join the columns to complete the indexes. This type of index is helpful when retrieving data from large tables such as database warehouse fact tables for queries such as queries for filtering, aggregating, grouping.
Let us create a Columnstore index and compare the results with standard non clustered index.
Expand the Indexes tab inside a table where you want to create the Columnstore index. Right click Indexses and select New Index. Under this, you will see in the below image, a new option called Non-Clustered Columnstore Index…
With this you will be taken to the index creation dialog box. Here, Date column is used to create the Non-Clustered Columnstore Index for FactFinance table.
Similarly, you can use T-SQL scripts to create Columnstore Indexes. Following script will create an index on FactFinace table in the AdventureWorksDenali database.
USE [AdventureWorksDWDenali]
GO
CREATE NONCLUSTERED COLUMNSTORE INDEX [csi_date] ON [dbo].[FactFinance]
(
[Date]
) ON [PRIMARY]
GO
To compare the results of Columnstore index with traditional index, let us create standard Non-Clustered Index on the same date column as shown in the below dialog box.
So Index creation also has a different interface. Also, in SQL Server 2012 filtered index creation has an interface support which is not there in previous versions.
After creating those indexes you will see following indexes in the SQL Server Management Studio.
So you have a different icon for the Columnstore index.
Let us try to retrieve some data using above to indexes.
You will see that same query is executing at but with different indexes. More rows are added to this table so that you can visualize the different. This table has 2522176 Rows.
USE [AdventureWorksDWDenali]
GO
SELECT DISTINCT [DATE]
FROM dbo.FactFinance WITH ( INDEX = [csi_date])
ORDER BY [DATE]
GO
SELECT DISTINCT [DATE]
FROM dbo.FactFinance WITH ( INDEX = [nci_date])
ORDER BY [DATE]
GO
Let us first analyze the execution plans for both queries.
From the above image, you can see that Query 1 (which uses the Columnstore Index) has 4 % cost while the Query 2 (which uses the Non-Clustered index) has cost of 96 %.
Let us now examine these queries with SET STATISTICS IO, TIME ON
| With Columnstore Index | With Non-Clustered Index | |
| CPU Time | 16 ms | 451 ms |
| Execution Time | 35 ms | 2,986 ms |
| Read Count | 49 | 18,316 |
Above results will tell you that columnstore is far better than the standard index. However, you need to analyze this case by case as for some cases having a Columnstore index will have negative impact.
Limitations
Following are the limitations of Columnstore Indexes.
· Cannot be Clustered Key or Primary Key
· Columnstore index has to be a Non-Clustered Index and it can be neither Clustered Key nor Primary Key.
· Cannot update tables with Column and following error will return if you try to update a table which has a Columnstore index.
Msg 35330, Level 15, State 1, Line 1
INSERT statement failed because data cannot be updated in a table with a columnstore index. Consider disabling the columnstore index before issuing the INSERT statement, then rebuilding the columnstore index after INSERT is complete.
· You can have only once Columnstore Index per table. After creating the first Columnstore index, option to create Columnstore Index will be disabled and if you try to create the index using T-SQL script following error will be returned.
Msg 35339, Level 16, State 1, Line 2
Multiple nonclustered columnstore indexes are not supported.
· Cannot be created with the INCLUDE keyword.
· Cannot be a unique index.
· Cannot be created on a view or indexed view.
· Cannot include a sparse column.
· Cannot have more than 1024 columns.
· If you need this much of columns for the Columnstore indexes, then obviously there is something wrong with the design.
· The following data types can be included in a columnstore index.
o Char, varchar, nchar and nvarchar (except varchar(max) and nvarchar(max))
o decimal (and numeric) (Except with precision greater than 18 digits.)
o int, bigint, smallint, and tinyint
o float and real
o bit
o money and smallmoney
o All date and time data types (except datetimeoffset with scale greater than 2)
· The following data types cannot be included in a columnstore index.
o binary and varbinary
o ntext, text, and image
o varchar(max) and nvarchar(max)
o uniqueidentifier
o rowversion (and timestamp)
o sql_variant
o decimal (and numeric) with precision greater than 18 digits
o datetimeoffset with scale greater than 2
o CLR types (hierarchyid and spatial types)
o xml
· Cannot Modify
Simply you are not allowed to use ALTEX INDEX syntax against Columnstore Indexes to modify the index. Drop and re-create the Columnstore index instead. Of course, if you want to disable or enable index, you can use ALTER INDEX syntax.
Friday, August 10, 2012
August 2012 Meet-up
We've put together a special meet-up for August 2012 with a special session and different meet-up location, just for a change. We also have a couple of transport options listed out below.
Session 1
TITLE: Using Extended Events
Performance issues? Debugging your stored proc? Deadlocks? How would you investigate and monitor these problems? Extended Events is the new monitoring platform. In this session we'll explore how to use extended events to monitor SQL Server and how it could be used as a potential replacement for SQL profiler.
SPEAKER: Prithiviraj Kulasingham, MVP
Session 2
TITLE: Anything-SQL Lightning Talks - 2nd Edition
A train of twelve 5-minute back-to-back presentations on various SQL Server aspects.
SPEAKERS:
- Abhinandana de Zoysa
- Avantha Siriwardana
- B.Umashanthan
- Dedunu Dhananjaya
- Dinesh Karunarathna
- Hasitha Kanchana
- Jayani Withanawasam
- Sanjeewa Jayawickarama
- Shamil Saleem
- Shane Carvalho
- Sriyantha Silva
- Supun Thrikawala
Entrance
Free for all.
Snacks and drinks provided.
Date and Time
August 15, 2012 6:00 PM Onwards
Location
Pearson Lanka (formerly eCollege)Regal Building, Orion City
752, Dr. Danister De Silva Mawatha
Colombo 09
Sri Lanka