Solved

SQL Query

Posted on 2011-03-21
4
290 Views
Last Modified: 2012-05-11
I have a SQL Query that takes some time to return answer.  Is there a way to speed up the response?
The table has about 5,000,000 rows of data.

SELECT vol FROM tblVolDelta13_18 WHERE [deltaId] = '50' and [loadTime] = '25200' and [expiryId] = '2' and [loadDate] = '40623'

Generally, the idea is to retreive the vol data for the latest date.  Running this query does take about 30 seconds to retreive the answer.

Thanks,
0
Comment
Question by:blueteam
4 Comments
 
LVL 32

Assisted Solution

by:ewangoya
ewangoya earned 25 total points
ID: 35184354

It may just be a case of indexes

Are all the fields in your where clause indexed
0
 
LVL 9

Accepted Solution

by:
Roman Gherman earned 25 total points
ID: 35184369
Hi,
You're doing checking for a string, why is that?
I think that those columns which you're filtering by are integers, aren't they?

I think the code should look like this:
SELECT vol FROM tblVolDelta13_18 WHERE [deltaId] = 50 and [loadTime] = 25200 and [expiryId] = 2 and [loadDate] = 40623

Open in new window


Plus try adding indexes where possible.
0
 
LVL 12

Expert Comment

by:Mohamed Abowarda
ID: 35185747
Check the database columns data type, probably you are using varchar instead of int, you should also update the query and remove the quotations to query about integers.
0
 
LVL 8

Expert Comment

by:PagodNaUtak
ID: 35186953
Or you can use paging for this scenario.

Have a look here:

http://forums.devx.com/showthread.php?t=155210
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now