Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to apeed up some queries on my Microsoft SQL Server Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
Speed up some queries on my Microsoft SQL Server 14-Jun-02
Category
Database Others
Language
Delphi 2.x
Views
113
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Daaron Dwyer 


What can I do to speed up some queries on my Microsoft SQL Server?

Answer:

I have found that queries like: 

select * from table1 innerjoin table2 on table1.field=table2.field 

...sometimes will query quickly, but takes time to return a result. 

The solution I have found to work is to insert the first query to a temporary 
table, then query the second, like: 


select * into #temptable from table1 innerjoin table2 on table1.field=table2.field 

select * from #temptable 


The "#temptable" can be anything starting with the pound sign.  The temporary table 
will be released when your connection is closed.

I have found what I think is the answer here-- table locking. 
When I query active tables, I fight with other applications having locks on various 
rows and tables.  When the query takes part into a temporary table, the lock is not 
there. 

This article then has a really silly premise, I concur. 

What should be used rather than temporary tables in a select statement is the "with 
(nolock)" feature that does a dirty read. Like: 

select * from BigTable with (nolock) 

rather than: 
select * into #tempTable from BigTable 

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC