I have a table that is --
30 Megabytes
90,000 rows
~65 columns
My query goes
SELECT city FROM table WHERE zip = 90210;
It will then find about 10 matching records.
I have an index on both zip and city.
This query takes on average anywhere from 0.80 seconds to 2.5 seconds.
Is this normal speed? I've been breaking my back trying to get it in
the sub 0.1 second range.
Thanks!
-Matt 5 1409
You should put an index an the zip column. That's all you can (and should)
do from the query optimizing point of view.
Markus
Mark I already have two separate indexes in place, one on zip, one on
city.
Is the physical size of the table slowing down the query?
Is it the 90k records, or the 65 columns?
For this particular query, only the index on the zip column will help you
(that doesn't mean, that the index on the city column can't help for other
queries - this only applied to this one particular query). As a general
rule, you should also take care not to place indexes that are not necessary,
because they can slow down INSERTs. Indexes should always be balanced
according to the concrete needs of a table. A good choice is to place
indexes on columns that have direct relations to other tables or that are
often used in a WHERE clause (like the zip column in your query).
65 columns for a table are quite a lot - are you sure that the data is
properly normalized (in case it is not, normalization would very likely lead
to better performence).
Also if it is normalized (although it's very rare that you need 65 columns
in a table if the data is normalized), it could make sense to split it up to
create 2 or more tables that are referenced to each other in a 1 : 1
relationship. You could group the data together in a way that you have those
columns in the same table that are mostly queried together. The less columns
you have, the better the performence will be.
The 90,000 rows should not be the problem because if you have that amount of
data to store, there's probably no way to reduce the number of rows. The
solution will most likely be to split the data up into more tables.
Markus
Markus,
Thank you for the very imformative reply. It makes complete sense.
I started splitting the table up per your suggestion and got immediate
results!
It's not my system, I'm just doing some contract work, so hopefully the
maintainers will be able to make some permanent normalization updates.
Thanks again,
-Matt
On 14/11/2005, MattPF wrote: SELECT city FROM table WHERE zip = 90210;
It will then find about 10 matching records.
I have an index on both zip and city.
A covering composite index on (zip, city) may help here.
ALTER TABLE table ADD INDEX (zip, city);
--
felix This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Ben Binskin |
last post by:
hi
Im just curious, im developing a web site for a client the content of
which is vehicles the database has a number of different methods to search
by, but as soon as you get to a singular vehicle...
|
by: DraguVaso |
last post by:
Hi,
I'm new to WebServices, and I'm doing some tests (with a small
VB.NET-application) to know the performance-difference between a WebService
and the 'normal'-way of getting data (just...
|
by: Rolan |
last post by:
There must be a way to enhance the performance of a query, or find a
plausible workaround, but I seem to be hitting a wall. I have tried a
few tweaks, however, there has been no improvement.
...
|
by: gerbski |
last post by:
Hi all,
I am relatively new to ADO, but up to now I got things working the way
I wanted. But now I've run into somethng really annoying.
I am working in MS Access. I am using an Access...
|
by: Himmel |
last post by:
Hello!
The reference database I currently use runs queries that pull data from hundreds of tables in order to create user-friendly form view. The problem is that these queries can take upwards of...
|
by: Andy_Khosravi |
last post by:
Background: Access 2003 (converted from A97 DB recently), database is
split into FE/BE with the FE residing on client machine.
I've got a question about how I can possibly optimize a query I've...
|
by: Neil |
last post by:
I'm running an update query in SQL 7 from QA, and it runs forever. Has been
running for 20 minutes so far! The query is quite simple: update a single
field in a table, based on a join with another...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM).
In this month's session, the creator of the excellent VBE...
|
by: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: Aftab Ahmad |
last post by:
Hello Experts!
I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
|
by: marcoviolo |
last post by:
Dear all,
I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
| |