Solved

SQL Query

Posted on 2011-03-21
4
318 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 32

Assisted Solution

by:Ephraim Wangoya
Ephraim Wangoya 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

751 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