All Questions
46
questions
6
votes
1
answer
424
views
How to see the execution plan of a multi-statement table valued function in SQL Server?
I have a view in SQL Server that calls a function. When I show the actual execution plan for querying the view, what happens inside the function is completely opaque though.
As a small example, I made ...
2
votes
1
answer
1k
views
SQL Server execution plan in XML for query is too large to be displayed or saved in full
I am trying to obtain the execution plan in XML for a large T-SQL query. I am able to run the query to obtain the execution plan.
However, the resulting XML execution plan text is too long to be fully ...
1
vote
2
answers
69
views
Why changing where statement to a variable cause query to be 4 times slower
I am inserting data from one table "Tags" from "Recovery" database into another table "Tags" in "R3" database
they all live in my laptop similar SQL Server ...
0
votes
1
answer
460
views
Why my query become too slow when number of records increased
I have an insert statement in SQL Server.
I tried it for a smaller subset, was fast
increased the number to 1milllion records and was fast 1 min 10 sec
now I doubled it and it seems stuck it has been ...
0
votes
1
answer
1k
views
how the columns order matters while index creation in sql server?
I have created one table EMP (name varchar(10),address varchar(10)) and Two indexes on both columns with only difference is order of column is changes. Index1(name,address) and index2(adress,name) and ...
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 #...
2
votes
1
answer
586
views
How to enhance query to make it run fast and less time?
I work on SQL server 2012 query I face issue : when run query return 10 rows for only one part
it take 50 second I try to run it in another time may be PC have more load
but it take same time 50 ...
1
vote
2
answers
4k
views
Estimate Rows vs Actual Rows, what is the impact on performance?
I have a query that performs very quickly but in production when server loads are high its performance is underwhelming. I have a suspicion that it might be the Estimated Rows being much lower than ...
3
votes
2
answers
357
views
How to avoid sort operator in a select query
In my select statement I have simple sub-query that grabbing last ExpirationDate within ControlNo.
This subquery significantly slows down the performance.
QuoteID is Clustered index on table ...
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.
...
3
votes
3
answers
173
views
Impact of variables in a paramatized SQL query
I have a parametrized query which looks like (With ? being the applications parameter):
SELECT * FROM tbl WHERE tbl_id = ?
What are the performance implications of adding a variable like so:
...
5
votes
1
answer
1k
views
How to find out what is represented by the intermediate value used in SQL Server execution plan
I'm learning how to read the actual execution plan in SQL Server. I have noticed that SQL Server tends to represent intermediate value used in the physical query plan as e.g. expr1006, expr1007 etc. (...
1
vote
1
answer
51
views
SQL How to optimize insert to table from temporary table
I created procedure where dynamically collecting from various projects (Databases) some records into temporary table and from that temporary table I am inserting into table. With WHERE statement , but ...
17
votes
5
answers
2k
views
Conditional UNION ALL in table function
So use case is as follows - there're some parameter, based on which I want to select data from one table or another.
create table dbo.TEST1 (id int primary key, name nvarchar(128))
create table dbo....
2
votes
2
answers
154
views
Weird join on on behavior in tsql [duplicate]
I recently found old code that uses JOIN JOIN ON ON instead of the more familiar JOIN ON JOIN ON syntax.
DECLARE @a TABLE (
val INT
)
DECLARE @b TABLE (
val INT
)
DECLARE @c TABLE (
val ...