Tag: performance

EF 4.1 code-first: difference between EF generated sql and custom sql

I have a question about sql generated by Entity Framework and the hand-writed one. In my project, I have some entities (they aren’t important really for this Q), for a simple example, when I use this code: var query = context.Employees.Select(e => new { PersonalCode = e.PersonelCode, Fname = e.Person.Fname, Family = e.Person.Family, Email = […]

strip html – Whos job is it?

In db I have : (have = existing situation. the DB has already has the data) Long html string (nvarchar max) user have : asp.net aspx page mission: extract from the whole html string 1 specific sentence – and show it to user options : 1) do the strip job in sql and transfer the […]

SQL Server: Joining by primary key or using separate queries?

I have a simple question regarding the dichotomy of joining two tables vs using 2 separate queries. I was hoping to find an existing question, but my search didn’t yield much (most questions were for more complex problems). For example, consider two tables, A and X, with a very simple schema: Table A +————-+————-+————-+ | […]

Select performance

Is it fair to say that it takes no time (compared to the nested SELECT) to make the second (outer) ‘SELECT’ from a result-set like this? SELECT some_column FROM ( SELECT some_column FROM some_table ) AS _alias

Should my view be much slower than my stored proc?

I have a view that I can’t seem to fully tune, so I tried converting it to a proc, moving one of my WHERE conditions that I use when querying into a parameter and using the parameter in my derived tables. View CREATE VIEW myView AS SELECT i.ItemCode , s.StoreID , ISNULL(SUM(s.TotalSales)) AS Sales FROM […]

Calculate COUNT in GROUP BY SQL query

I have query to calculate total amount by one product item below: SELECT p.[Id], COUNT(o.[Id]), SUM(o.[Amount]) FROM [dbo].[Order] o INNER JOIN [dbo].[Product] p ON p.[Id] = o.[ProductId] GROUP BY p.[Id] In this case, COUNT(o.[Id]) is number of unique orders by one product item. But instead of COUNT(o.[Id]) I would like to calculate number of orders […]

Subquery in view runs slow

Hello i have an issue with my view. The Subquery causes the view to run very slowly. SELECT dbo.Calls.CallID ,dbo.Calls.StartTime ,dbo.Calls.EndTime ,dbo.Connections.Connectionname ,dbo.Repositorys.RepositoryName ,REPLACE(dbo.Calls.Querytime ,’,’ ,’.’) AS Querytijd ,dbo.Calls.Uur ,dbo.Calls.DayOfMonth ,REPLACE( ( SELECT MAX(Querytime) AS MaxQueryTime FROM dbo.Calls AS C WHERE ( DATEPART(yyyy ,StartTime)=DATEPART(yyyy ,dbo.Calls.StartTime) ) AND (DATEPART(M ,StartTime)=DATEPART(M,dbo.Calls.StartTime)) AND (DayOfMonth=dbo.Calls.DayOfMonth) AND (Uur=dbo.Calls.Uur) AND ( […]

SQL Server performance fast only when refresh the stored procedure

I can run a stored procedure multiple times and it wont hit it’s cache: (1665ms is duration column) But if I then alter the stored procedure changing nothing: (240ms is duration column) Problem: how to get the stored procedure to always be fast (on the second and next calls)

SQL Server Connected to Hadoop – Thoughts and Challenges of Implementation

I wanted to broach the issue of SQL Server’s Hadoop distribution called HDInsight. Given that there is a connection provided to Hadoop, does anyone have experience with HDInsight and particularly a comparison between the Hadoop / SQL Server connector and HDIinsight / SQL Server from a real life DTP scenario or personal 1 node installation? […]

Profiling and output caching in ASP.NET MVC

So I was recently hired by a big department of a Fortune 50 company, straight out of college. I’ll be supporting a brand new ASP.NET MVC app – over a million lines of code written by contractors over 4 years. The system works great with up to 3 or 4 simultaneous requests, but becomes very […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.