Thursday, February 10, 2011

SQL Server Reorganizing and Rebuilding Indexes

"The SQL Server Database Engine automatically maintains indexes whenever insert, update, or delete operations are made to the underlying data. Over time these modifications can cause the information in the index to become scattered in the database (fragmented). Fragmentation exists when indexes have pages in which the logical ordering, based on the key value, does not match the physical ordering inside the data file. Heavily fragmented indexes can degrade query performance and cause your application to respond slowly."

"You can remedy index fragmentation by either reorganizing an index or by rebuilding an index. For partitioned indexes built on a partition scheme, you can use either of these methods on a complete index or on a single partition of an index."

http://technet.microsoft.com/en-us/library/ms187874.aspx

http://technet.microsoft.com/en-us/library/ms189858.aspx

http://technet.microsoft.com/en-us/library/ms188388.aspx

Friday, February 4, 2011

SQL Server Data Type Mappings (ADO.NET)

"SQL Server and the .NET Framework are based on different type systems. For example, the .NET Framework Decimal structure has a maximum scale of 28, whereas the SQL Server decimal and numeric data types have a maximum scale of 38. To maintain data integrity when reading and writing data, the SqlDataReader exposes SQL Server–specific typed accessor methods that return objects of System.Data.SqlTypes as well as accessor methods that return .NET Framework types. Both SQL Server types and .NET Framework types are also represented by enumerations in the DbType and SqlDbType classes, which you can use when specifying SqlParameter data types."

The following article shows the inferred .NET Framework type, the DbType and SqlDbType enumerations, and the accessor methods for the SqlDataReader.

http://msdn.microsoft.com/en-us/library/cc716729.aspx

Extending Base Type Functionality with Extension Methods

"Extension methods allow a developer to tack on her own methods to an existing class in the .NET Framework. Extension methods make it easy to add functionality to an existing type using a natural syntax. Also, since the extension methods appear in Visual Studio's IntelliSense drop-down list, they are easier to find and use than wrapper class equivalents."

http://www.4guysfromrolla.com/articles/120507-1.aspx

http://dotnetslackers.com/articles/aspnet/5-Helpful-DateTime-Extension-Methods.aspx

http://www.lostechies.com/blogs/joshuaflanagan/archive/2011/02/03/helpful-datetime-extension-methods-for-dealing-with-time-zones.aspx

Thursday, February 3, 2011

Comparing the Different Options for Hosting a Dedicated Server

"Once you crunch the numbers, finding a provider that hosts dedicated servers probably looks like a pretty good idea. Especially compared to throwing resources, time and people into supporting dedicated servers in-house or through traditional colocation. But if you're really serious about not pouring resources in to managing the hardware and OS day and night, you need some serious hosting. And that's exactly what Managed Hosting from Rackspace is."

http://www.rackspace.com/managed_hosting/dedicated_servers.php

Wednesday, February 2, 2011

Response.Close()

Interesting article on Dynamic Compression and Response.Close().

http://forums.iis.net/t/1152058.aspx

I found myself researching Response.Close() recently due to an issue with streaming attachments back to the browser.

The following code had always worked in the past, but for one particular environment we found that not all of the data was being written back in the BinaryWrite.

Response.Buffer = False
Response.ClearHeaders()
Response.ContentType = File.FileType
Response.AddHeader("Content-Disposition", "attachment; filename=" & File.FileName)
Response.BinaryWrite(File.FileData)
Response.Close()
Response.End()


Removing the Response.Close() fixed the problem. It was likely an issue with the load balancer in that environment, which wasn't present in the other environments.

The absence of the Response.Close() works in all situations, so I've decided to standardize on not using Response.Close() unless there are obvious reasons otherwise.