5
votes
Accepted
Is my query having Parameter Sniffing performance issue
nope
You don't have a parameter sniffing problem because you don't have any parameters. You are using local variables, which means you'll always get the same density vector estimate no matter which ...
4
votes
Accepted
Will the query time increase?
Think of a telephone book.
Does it take longer to search for a name if a telephone book for a larger city, with thousands or millions of people?
Yes, of course it does.
But doubling the number of ...
3
votes
How do I tell Postgres to only scan the newest values in this query?
It's the classic "Top-N by category" problem, with a bit of a plot twist.
Fastest solution will probably be a lateral join. This allows executing a join with a dependent subquery.
If you ...
1
vote
Will the query time increase?
Will it increase? Almost certainly.
By how much? As with all things, it depends.
If you are finding rows by a single values on a uniquely-indexed field, the query can use an index (possibly the ne ...
1
vote
transactions without a corresponding session in sql server
My guess is that they belong to internal sessions used by SQL Server engine. I have an instance on my desktop, which I just started in order to check that, and after executing that same query the ...
1
vote
Is my query having Parameter Sniffing performance issue
ymmv
A further option/improvement to @ErikDarling's answer is to use window functions instead of those CROSS APPLYs.
DECLARE
@orgId integer = 22,
@salesperson integer = 0,
@sql nvarchar(...
1
vote
Accepted
Sql Server: Query to parse and validate codes
One relational way you can do this is by splitting your #SourceData first (fortunately you have access to the STRING_SPLIT() function despite being on an outdated version of SQL Server), then getting ...
1
vote
Sql Server: Query to parse and validate codes
-- first thing that comes to mind:
SELECT
sd.ID
, sd.Codes
, CASE
WHEN NOT EXISTS (
SELECT x.[value]
FROM string_split(sd.Codes, ';') as x
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
query-performance × 3132performance × 2104
sql-server × 987
mysql × 879
postgresql × 684
optimization × 531
execution-plan × 297
index × 241
postgresql-performance × 140
index-tuning × 126
performance-tuning × 125
join × 124
database-design × 114
query × 113
oracle × 112
sql-server-2012 × 103
sql-server-2016 × 92
sql-server-2014 × 88
mariadb × 86
sql-server-2008-r2 × 82
t-sql × 79
subquery × 71
sql-server-2008 × 64
azure-sql-database × 49
mysql-5.7 × 48