Skip to main content

All Questions

0 votes
1 answer
53 views

WHEN run query it take too much time although it return small number or records?

I work on SQL server 2012 I face issue when run query below it take 9 minutes to return 900 rows only SELECT fmat.Value as PLID,c.CodeTypeId, COUNT(DISTINCT tr.PartID) [#partsHasCodes] into #...
ahmed barbary's user avatar
6 votes
3 answers
442 views

Same query runs faster when out of proc

We have a specific query that runs a lot slower when inside a proc. I have to add here that it is enclosed within a two level-cursor. However, both cursors have an iteration result-set of one line. ...
George Menoutis's user avatar
0 votes
1 answer
894 views

Comparing stored procedure execution plan at different queries

When I compare execution plans of stored procedures, it only does the first one. I want to compare query 3 which is the main SP but I just am not able to. Is there a way to do this in SQL Server ...
Mike Flynn's user avatar
  • 24.1k
2 votes
1 answer
363 views

What's the difference between a temporary #Stored procedure vs a phisical proc in terms of performance or execution plan?

main difference between those database objects
jthalliens's user avatar
0 votes
1 answer
73 views

use variables in query instead of stored procedure parameters

I have a stored procedure with some parameters (I've used generic type and name, just for the example). When I have it like the code bellow, it runs in two minutes: create procedure [dbo].[name] ...
Buda Gavril's user avatar
  • 21.6k
-1 votes
2 answers
87 views

More Efficient Union Statement Than This?

I'm trying to wire up some generic search results, and would like it to perform as well as I could possibly make it happen. It's not terrible right now, but I feel like I could potentially improve ...
Middle Class Lowlife's user avatar
1 vote
3 answers
3k views

Search from Multiple columns in Where clause for SQL Server

We have a stored procedure that is used to allow users to search in a table with 20 million records and 40 columns wide. There are about 20 different columns they can search on (any combination) from ...
waazi's user avatar
  • 25
0 votes
0 answers
80 views

Full-text search Stored Procedure runs slowly, except when it runs fast

I just don't get it. The results for calling the stored procedure below come back within a few seconds or less. But when the @SearchPhrase parameter gets changed, it takes minutes to complete. You can ...
Jarvis's user avatar
  • 691
1 vote
1 answer
783 views

The same SQL runs slower or faster with the same parameters [duplicate]

I have a query that runs extremely fast (1 sec) see below: SELECT * FROM ( select ROW_NUMBER() OVER ( ORDER BY [Rank] DESC ) AS RowNum, * FROM [product].[FnSearchKeyword]('basic', null, ...
Jeferson Tenorio's user avatar
5 votes
1 answer
7k views

Find out the slow running stored procedure [duplicate]

Possible Duplicate: How to find slowest queries In Sql Server 2008, is there any option to find out which stored procedure running slowly among all (When the no. of stored procedures is very ...
gee'K'iran's user avatar
2 votes
1 answer
381 views

How does SQL Server utilize the query plan if the stored procedure is used for bulk select and single row select?

I've got a stored procedure that is used to process about 90,000 records to return various information; which I just join to a SQL table to filter down the records to run for (which is loaded from ...
user1070202's user avatar
2 votes
7 answers
2k views

Stored Procedure Execution Plan - Data Manipulation

I have a stored proc that processes a large amount of data (about 5m rows in this example). The performance varies wildly. I've had the process running in as little as 15 minutes and seen it run for ...
Cade Roux's user avatar
  • 89.2k
4 votes
6 answers
6k views

Different Execution Plan for the same Stored Procedure

We have a query that is taking around 5 sec on our production system, but on our mirror system (as identical as possible to production) and dev systems it takes under 1 second. We have checked out ...
Robert Wagner's user avatar
7 votes
2 answers
7k views

Different execution plan when executing statement directly and from stored procedure

While developing a new query at work I wrote it and profiled it in SQL Query Analyzer. The query was performing really good without any table scans but when I encapsulated it within a stored procedure ...
Markus Olsson's user avatar