Run Faster Queries

Parra

Well-known Member
Joined
Feb 21, 2002
Messages
752
The old analyst in the company had a database for every year worth of data. I just combined the data onto one database and I would like the queries to run faster. What could I do? What do you do? Any suggestions would be great.
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Hi Parra,

One moethod would be to 'pre-filter' the data before it gets to the query.

Say you have to run a bunch of calculations is a query on your main table for a period of time. Instead of putting criteria in this query, make a new query without the calculations, and all the necessary fields, and put the date criteria there. You can optionaly make it a 'make table' query. Now have the calculation query look to the results of this filtered query, or the new made table. That way, you're not running calculations on records you're not interested in analyzing.

The idea is, give your slow query as small a dataset as possible to perform calculations on.

HTH,
 
Upvote 0
Hi Corticus, So pretty much run a query of a query. I like your suggestion. But what if I have to use all the data in the table? I know there might not be anything I can do, but it can't hurt to ask.

Thanks
Parra
 
Upvote 0
indexing

You're looking at all the records in your main table at once?

That seems like a lot of data (multiple years) to have to look at at one time. What is the purpose of the query? Is it all calculations?

Does your SQL have a 'WHERE' in it?

Another option is indexing, but if it isn's a select query (with criteria) but just calculations, I don't think indexing will help.

The idea of indexing is, say you want to pull all of "John Qs" records. You make a customer table, and give "John Q" a number ID, such. Then, in your select quey, your criteria would look to filter by this ID, and not the actual name. You query numbers much faster than text strings.

We're actually dealing with a problem like this where I work. We have a large client database (~1 million) records, and the db was initially set up to do all client searches and joins on the client's social security number. Unfortunately, this has to be a text field, because some clients have letters in their social security number (I know their not supposed to, but because of privacy issues, our case managers have started using a generic client ID instead of a social, but it still goes in the social field). When searching by the socials, it is very slow. We're in the process of assigning the clients a number ID, and this will query much faster.

HTH,
 
Upvote 0

Forum statistics

Threads
1,221,508
Messages
6,160,222
Members
451,631
Latest member
coffiajoseph

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top