All Questions
192
questions
0
votes
1
answer
76
views
How to ensure use of an index?
I have the following query:
SELECT cp.ID_Case
FROM dbo.CaseParty cp (NOLOCK)
JOIN dbo.Client cli (NOLOCK) ON CASE
WHEN cli.ClientType = 'atty' AND cp.ID_ClientAttorney = cli.ID_Client THEN 1
...
0
votes
0
answers
97
views
Azure Managed Instance - Slow Index Delete
I have a large table in Azure SQL Managed Instance. The table has ~ 550 million rows and is ~ 250 gb in size. The table has a clustered index on a surrogate key which is auto generated by the system ...
0
votes
1
answer
108
views
Delete statement takes too long
I have a ProfileAvatars table with 1000 rows that is the parent table for UserProfile table with 16,557,010 rows.
When I add a new picture (without any child record in UserProfile) and I want to ...
0
votes
1
answer
296
views
Optimizing the execution plan of SQL Server query with subquery in where condition
There are two tables one with the actual fact data(table1) and the other table(table2) with more like a tracker information on date.
I am trying to get all the fact data from table1 where the date ...
1
vote
1
answer
78
views
Similar Query different execution plan and performance
This is the script I use to generate 10M rows on Clients table from 200 different cities. (It took 11 minutes on a desktop PC)
*Important note at the end
-- Crear la tabla Clientes
CREATE TABLE ...
6
votes
1
answer
423
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 ...
0
votes
1
answer
187
views
How to prevent SQL Server from running the same subquery multiple times
I have a query that follows the following structure:
SELECT *
FROM
... <generated code> ...
(SELECT <fields>,
CASE(SELECT TOP 1 ID FROM [Configuration] WHERE IsDefault=...
0
votes
0
answers
67
views
SQL INNER JOIN vs WHERE IN big performance difference
I have read multiple sources and still don't understand where a big difference comes from in a query I have for Microsoft SQL Server.
I need to count different alerts linked to vehicles (IdMateriel is ...
0
votes
1
answer
130
views
SQL Server 2022 : unique index with two columns not working correctly
I have a table with users with over 50000000 entries. I want to check for the presence of already registered users on the server and I execute this request.
SELECT *
FROM
(SELECT TOP (1000) *
...
0
votes
2
answers
372
views
How to fine tune SQL Server query execution plan generation?
I have a large "Deals" table (1.3 million rows) that needs to be displayed on a paginated grid in my application, the application also includes filters to help the user search through those ...
0
votes
0
answers
68
views
Why doesn't computed column calculation show up in the the Execution Plan?
I have a table with a computed column. It is not persisted.
create table dbo.Cases (
...
CaseName varchar(20) not null,
NickName AS (dbo.fn_ParseCaseNickName(CaseName)),
...
)
When I execute ...
0
votes
1
answer
1k
views
SQL Server error - The SET SHOWPLAN statements must be the only statements in the batch
I am trying to generate a showplan table in SQL Server. I am getting this error when I try to do this
Msg 1067, Level 15, State 1, Line 0
The SET SHOWPLAN statements must be the only statements in ...
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
1
answer
874
views
SQL execution plan has sort
I'm using the AdventureWorks database, ran the below query:
-- 9
select *
from Production.ProductModel
where not exists
(
select 1
from Production.Product
where Production.Product....
0
votes
0
answers
98
views
Insert of records into SQL Server is slow whereas select is quicker
I am trying to improve the performance of insert in SQL Server.
INSERT INTO [dbo].[GroupCustomerAccountProductRebates]([GroupId],[GroupName],[ProductId],[ManufacturerProductCode],[ProductDescription],[...