December 6, 2019 at 9:08 am
hi ,
i getting result of query 65954 rows its take 20 seconds how i can i make query fast.
immad
December 6, 2019 at 9:12 am
Maybe 20 seconds is fast. Care to provide more information, please - query, execution plan, table DDL, SQL Server version and edition, server RAM, max server memory, no of processors, maxdop, cost threshold for parallelism and anything else you think may be relevant?
John
December 6, 2019 at 9:44 am
one thing i'd add to john's very valid points... do you start getting results immediately, but it takes 20 seconds to complete? or does it take 20 seconds and you get your results after
if you start getting rows straight away then it's likely a table scan issue. if it's the other way then we need a copy of the query
MVDBA
December 6, 2019 at 10:05 am
it take 20 seconds and results get after
immad
December 6, 2019 at 11:13 am
you have to give us more, even just the query definition
we can't help you unless you share a bit more information
MVDBA
December 6, 2019 at 11:32 am
Its Solved i use temp table
Thanks
immad
December 6, 2019 at 2:46 pm
Well, just in case you have more issues like this, I'd like to recommend my books. Query tuning is a pretty vast topic. Follow the links below.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
December 7, 2019 at 12:56 am
hi ,
i getting result of query 65954 rows its take 20 seconds how i can i make query fast.
It's easy... just hit the "Go faster" button.
Its Solved i use temp table
Thanks
That's one of them. 😉
--Jeff Moden
Change is inevitable... Change for the better is not.
December 9, 2019 at 9:43 am
Different Ways to Improve SQL Query Performance
Avoid Multiple Joins in a Single Query. ...
Eliminate Cursors from the Query. ...
Avoid Use of Non-correlated Scalar Sub Query. ...
Avoid Multi-statement Table Valued Functions (TVFs) ...
Creation and Use of Indexes. ...
Understand the Data. ...
Create a Highly Selective Index. ...
Position a Column in an Index.
December 9, 2019 at 12:03 pm
Different Ways to Improve SQL Query Performance
Avoid Multiple Joins in a Single Query. ...
Whoa!
No. Absolutely not. You structure your data as is appropriate with primary keys and enforced referential constraints. Then, you write queries that correctly use these keys as join criteria. Possibly indexing some of the foreign keys. However, you don't avoid joins or try to eliminate joins or make your relational database engine non-relational as a query tuning choice. No. In fact, foreign keys and joins can make queries faster.
I have, what is now an VERY old story, about a 86 table join that ran in about 500ms. Now, it took 5 minutes to compile, but it ran in 500ms. Joins are not an inherent problem in a relational storage engine. It's built around the idea. Please, be cautious offering this kind of advice.
And this one:
"Position a Column in an Index"
What does that even mean? Rearrange the key order to better support a query? Add a column as INCLUDE to make an index covering? I can't tell.
Sorry, I don't like being critical on posts, but perpetuating bad information hurts us all. Better to try to clarify things than leave them laying about.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
December 9, 2019 at 12:21 pm
Grant is correct, if you put your database into 3rd normal form you will have to join. In my honest opinion getting 3nf is the most important part of getting not only performance, but also easy coding
one of the lessons I learned early in my career was that your database table structure should not force a specific coding pattern(ie forcing you to use functions)
i would add - avoid using redundant joins, this can be really tricky when you use views
MVDBA
December 9, 2019 at 12:39 pm
Position a Column in an Index.
are you talking about choosing the order of columns in an index?
MVDBA
Viewing 12 posts - 1 through 11 (of 11 total)
You must be logged in to reply to this topic. Login to reply