background preloader

Work

Facebook Twitter

Query Performance Tuning (SQL Server Compact) Creating useful indexes is one of the most important ways to achieve better query performance.

Query Performance Tuning (SQL Server Compact)

Useful indexes help you find data with fewer disk I/O operations and less system resource usage. To create useful indexes, you much understand how the data is used, the types of queries and the frequencies they are run, and how the query processor can use indexes to find your data quickly. When you choose what indexes to create, examine your critical queries, the performance of which will affect user experience most. Creating Indexes with Included Columns. A nonclustered index can be extended by including nonkey columns in addition to the index key columns.

Creating Indexes with Included Columns

The nonkey columns are stored at the leaf level of the index b-tree. Adding nonkey columns to the index uses more disk space to store the index. In particular, adding varchar(max), nvarchar(max), varbinary(max), or xml data types as nonkey columns may significantly increase disk space requirements, because the column values are copied into the index leaf level and also remain in the table or clustered index. Tibor Karaszi : Non-trusted constraints and performance. (See my part 1 article about non-trusted constraints in general: The optimizer is a pretty smart little animal.

Tibor Karaszi : Non-trusted constraints and performance

It can even use constraints to eliminate some data access or part of a query. That assumes however that the constraint is trusted. For example, for a check constraint: USE Adventureworks SET STATISTICS IO ON --Also check the execution plan SELECT AVG(OrderQty) FROM Sales.SalesOrderDetail SELECT AVG(OrderQty) FROM Sales.SalesOrderDetail WHERE UnitPrice < 0 Note that the table isn't even accessed for the second query. SELECT OBJECT_NAME(parent_object_id) AS table_name, name, definition FROM sys.check_constraints WHERE parent_object_id = OBJECT_ID('sales.salesorderdetail') ORDER BY table_name. Disabling SQL Server Table Constraints. Tibor Karaszi : Non-trusted constraints. A discussion in the newsgroups before the holidays lead to trusted constraints and performance.

Tibor Karaszi : Non-trusted constraints

This inspired me to blog about it, but I decided to have some vacation first :-). Instead of having one long article, I'll do a two-part. This one is about non-trusted constraints in general, and another one will follow about non-trusted constraints and performance. As you might know, we can disable check and foreign key constraints. This can be done when we create the constraint, for instance: Sql server - Indexes for inner joins with where clause.

SQL Tips and Tricks. [Notes from Pinal]: Search on the internet about ‘Shrinking Database’, you will find plenty of advice why it is bad and it should not be done.

SQL Tips and Tricks

If you do not believe me, just try it yourself. Even I have blogged about it before that it is an absolutely bad thing to do. However, there are very few blogs which talks about how to solve this ancient problem. The reason, I call it ancient problem is that there are quite a few organizations which are doing this for many years and they have many different places where they have included Shrinking Database code. There are quite a few places, where I see that people have created database jobs to shrink the database. Linchpin People are database coaches and wellness experts for a data driven world. Often when analyzing a SQL Server Instance I come across jobs that are automating shrinking a database file. Below is the script I use to search for the word shrink in any tsql job step. DECLARE @search VARCHAR(100)SET @Search = 'shrink'SELECT A.

Insert Data From One Table to Another Table – INSERT INTO SELECT – SELECT INTO TABLE. Following three questions are many time asked on this blog.

Insert Data From One Table to Another Table – INSERT INTO SELECT – SELECT INTO TABLE

How to insert data from one table to another table efficiently? How to insert data from one table using where condition to anther table? Loading a Flat File as fast as possible into SQL Server with SSIS. Since we set the ETL World Record with the introduction of SQL2008, a lot of insights, tips & tricks have been published on what it takes to load data fast into SQL (see also the Data loading Performance Guide).

Loading a Flat File as fast as possible into SQL Server with SSIS

The trick described below is one to remember if you are being challenged to load a single flat file as fast as possible into SQL Server. Challenge: Loading the data from a single large file as fast as possible into a table The fastest way to do this is to build an SSIS package to handle the pre-processing of the data type conversions so this doesn’t have to be done on the SQL Server side, saving precious CPU ticks and more important – latency. Next thing is to run this SSIS package on the SQL Server itself and use a fast, low latency, in-memory connection to eliminate the network stack overhead. Step 1) Check the speed of your data source. Load 1TB in less than 1 hour - Microsoft SQL Server Development Customer Advisory Team.

This project was done using SQL Server 2005 Enterprise Edition (with SP1 beta) using the BULK INSERT command with 60 parallel input files, each of approximately 16.67 GB.

Load 1TB in less than 1 hour - Microsoft SQL Server Development Customer Advisory Team

The best time I got was 50 minutes. Hewlett Packard was kind enough to loan me some time one night on the machine they use to do the TPC-C tests. It is an Itanium2 Superdome with 64 1.6GHZ 9M () CPUs. For the insert tests the system was equipped with 256GB of RAM. The HP SAN configuration is rated at 14GB per second throughput. BEST PRACTICES and LESSIONS LEARNED Here is a list of things we learned during this project that should be helpful in your projects. Run as many load processes as you have available CPUs. The files were on the same SAN as the database, but on different drive arrays. The database was in BULK LOGGED mode, so there was very little transaction log activity. How to point Log4net to its configuration file.

'RE: Is there a way to use log4net without the App.Config file all-together? Chapter 1. Common Logging. There are a variety of logging implementations for .NET currently in use, log4net, Enterprise Library Logging, NLog, to name the most popular.

Chapter 1. Common Logging

The downside of having differerent implementation is that they do not share a common interface and therefore impose a particular logging implementation on the users of your library. Moving log4net config out of App.config.