Often when testing the performance of a ASP.Net website you need to see how the site will perform under extreme conditions. This is easy to do in a virtual environment where you can reduce the number of CPUs or available RAM.
I use Google's Chrome browser a lot. Its fast, websites display correctly and there's usually less problems.
But this week I started getting problems with webpages hanging in Google Chrome. I tested this on a couple of different PC's and found that it affected both Windows and Mac OS X. After further testing I discovered the problems only occurred on website with Flash. In each case the page would appear to forever be loading and Google Chrome Browser would eventually stop responding.
After disabling Flash, Chrome is working as fast if not faster than it used to.
How to disable Flash in Google Chrome Browser
Open a new tab in google chrome
In the address bar type: about:plugins then hit the 'enter' key. Ignore the suggestions that come up.
Locate the entry for "Flash" or "Shockwave Flash". (Note: you may have two entries for Flash, if so apply the next step to both copies of Flash).
Click the Disable link for flash
After disabling flash, website should become responsive again.
Note that by disabling flash some sites may not work correctly if they rely too much on flash. In which case you can follow the above steps to enable flash. There will be an "Enable" link if flash is already disabled.
Microsoft has revoked 28 of its security certificates via Windows Update today as part of their security advisory 278973.
The certificates have been revoked following the Flame malware attack that involved the use of fraudulent Microsoft digital certificates to by pass some security measures in windows to install the malware.
This patch should be available on Windows Update now for Windows XP SP3, Windows Vista, Windows Server 2003, Windows Server 2008, Windows 7.
You should consider applying the update to all windows machines immediately.
If you've restored a database onto another server, you may get the following error message when adding user logins to the database:
Create failed for User 'TMS'. (Microsoft.SqlServer.Smo)
User, group, or role 'TMS' already exists in the current database. (Microsoft SQL Server, Error: 15023)
To fix this there are two different methods depending on the version of SQL Server you are using. Both of these commands re-map the user's Security Identifier (SID) to match the sql server login's SID.
SQL Server 2008 / SQL Server 2008 R2
If you have already created the server login for the user, run this in the database with the login problem. (Change 'user' to be the database username you wish to fix, and 'serverlogin' is the sql server login to map the user to).
If you have already created the server login for the user, run this in the database with the login problem. (Change 'user' to be the username you wish to fix).
EXEC sp_change_users_login 'Auto_Fix', 'user'
Note that sp_change_users_login has be deprecated in SQL Server, future versions will require using ALTER USER.
Read the two below functions - they return the same thing, but one is more effecient than the other. If you can't see why, head over to Rob's post that shows the execution plans for a great explaination.
CREATE FUNCTION dbo.FetchSales_inline(@salespersonid int, @orderyear int)
RETURNS TABLE AS
RETURN (
SELECT e.LoginID as EmployeeLogin, o.OrderDate, o.SalesOrderID
FROM Sales.SalesOrderHeader AS o
LEFT JOIN HumanResources.Employee AS e
ON e.EmployeeID = o.SalesPersonID
WHERE o.SalesPersonID = @salespersonid
AND o.OrderDate >= DATEADD(year,@orderyear-2000,'20000101')
AND o.OrderDate < DATEADD(year,@orderyear-2000+1,'20000101')
)
;
GO
CREATE FUNCTION dbo.FetchSales_multi(@salespersonid int, @orderyear int)
RETURNS @results TABLE (
EmployeeLogin nvarchar(512),
OrderDate datetime,
SalesOrderID int
)
AS
BEGIN
INSERT @results (EmployeeLogin, OrderDate, SalesOrderID)
SELECT e.LoginID, o.OrderDate, o.SalesOrderID
FROM Sales.SalesOrderHeader AS o
LEFT JOIN HumanResources.Employee AS e
ON e.EmployeeID = o.SalesPersonID
WHERE o.SalesPersonID = @salespersonid
AND o.OrderDate >= DATEADD(year,@orderyear-2000,'20000101')
AND o.OrderDate < DATEADD(year,@orderyear-2000+1,'20000101')
;
RETURN
END
;
GO
I came across an interesting problem last night - a stored procedure that had been created years ago was suddenly coming up with this error message:
UPDATE failed because the following SET options have incorrect settings:
'ANSI_NULLS, QUOTED_IDENTIFIER'. Verify that SET options are correct for use with indexed views
and/or indexes on computed columns and/or filtered indexes and/or query notifications and/or XML
data type methods and/or spatial index operations.
This error message means the settings for ANSI_NULLS and QUOTED_IDENTIFIER were different at the time the procedure was created compared to when the table was created. You will notice that whenever you script out an object from sql server management studio that it will add the SET options at the top of the script. In this case it appears the stored procedure was created without the correct SET options.
To fix the problem, you will need to recreate / alter the stored procedure with the correct SET options turned on before the CREATE PROCEDURE / ALTER PROCEDURE statement.
SET NUMERIC_ROUNDABORT OFF
GO
SET ANSI_PADDING, ANSI_WARNINGS, CONCAT_NULL_YIELDS_NULL, ARITHABORT, QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
alter procedure dbo.myprocedure
....(stored procedure body)
Seeing as you've already had this problem once - it is worthwhile checking your entire database to see if there are any other procedures creates with QUOTED_IDENTIFIER set off. Luckily Andrei Volkov has already provided the answer on how to do this:
SELECT
SCHEMA_NAME(s.schema_id) + '.' + s.name AS name,
s.create_date,
s.modify_date,
OBJECTPROPERTY(s.object_id,'ExecIsQuotedIdentOn') AS IsQuotedIdentOn
FROM sys.objects s
WHERE
s.type IN ('P','TR','V','IF','FN','TF')
AND OBJECTPROPERTY(s.object_id,'ExecIsQuotedIdentOn') = 0
ORDER BY SCHEMA_NAME(s.schema_id) + '.' + s.name DESC
If you are trying to determine which rows are different between two sets, the usual method is to create a query comparing table1.Column1 != table2.Column1 but this doesn't check for rows where one of these columns is null.
isnull(table1.Column1,-1) != isnull(table2.Column1,-1) might seem like a good way to compare nullable columns - but the performance of this is still not optimal.
Paul's article details the different query plans that are created by using ISNULL and COALESCE and INTERSECT to do the comparisons, including the internal predicates that SQL Server uses to fulfill the query.
In short an INTERSECT handles null comparisons and is certainly much simpler to write. Below is a quick sample of the INTERSECT example Paul gives (for my own reference), but I highly recommend reading the article for the full details.
SELECT *
FROM table1 as T1
JOIN table2 as T2 ON T1.pk = T2.pk
WHERE NOT EXISTS
(SELECT T1.* INTERSECT T2.*)