I've got a table t with rows a,b,c,d,e,f
and a single index i on a,b,c,d,e,f
The query is:
SELECT * FROM t WHERE a="something" AND b="something" AND c="something"
ORDER BY d, e, f LIMIT 100;
now, table t may have millions of rows.
Is this query efficient ? Any comments?
Mike 2 1200
siliconmike wrote: I've got a table t with rows a,b,c,d,e,f and a single index i on a,b,c,d,e,f
The query is:
SELECT * FROM t WHERE a="something" AND b="something" AND c="something" ORDER BY d, e, f LIMIT 100;
now, table t may have millions of rows.
Is this query efficient ? Any comments?
If a,b and c are indexed and their values in combined match only to a
few thousands of rows, then the query should be pretty fast.
If you don't have indexes or they are for some reason not used, the
database will have to check each and every row in database, which might
take a while. Also, if values match to a large amount of rows, the query
will propably slow down.
Explain tells you more:
EXPLAIN SELECT * FROM t WHERE a="something" AND b="something" AND
c="something" ORDER BY d, e, f LIMIT 100;
siliconmike wrote: and a single index i on a,b,c,d,e,f
SELECT * FROM t WHERE a="something" AND b="something" AND c="something" ORDER BY d, e, f LIMIT 100;
You probably need at least one additional index, defined on columns (d,
e, f).
Read this page: http://dev.mysql.com/doc/mysql/en/mu...n-indexes.html
And also see additional explanation that I wrote in a posting last year: http://groups-beta.google.com/group/...19b977f48d3f63
Regards,
Bill K. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: dogu |
last post by:
Noob alert.
Code is below.
File is saved as a .php.
What I'm trying to do:
User uses 'select' box drop down list to pick a value.
Value ($site) is derived from a db query. This works fine....
|
by: shank |
last post by:
1) I'm getting this error: Syntax error (missing operator) in query
expression on the below statement. Can I get some advice.
2) I searched ASPFAQ and came up blank. Where can find the "rules"...
|
by: Brian Oster |
last post by:
After applying security patch MS03-031 (Sql server ver 8.00.818) a
query that used to execute in under 2 seconds, now takes over 8
Minutes to complete. Any ideas on what the heck might be going...
|
by: DFS |
last post by:
This UNION query is very slow. With only 3,000 records in the Parent table
and 7,000 records in the Child table, it takes about 60 seconds to run and
returns about 2200 records.
Any ideas on...
|
by: wiredog |
last post by:
I am struggling rewriting my query from MS Access' IIF, Then to SQL
Servers TSQL language. I am hoping some one can give me some
guidance. I believe I have the first portion of the query correct...
|
by: d.p. |
last post by:
Hi all,
I'm using MS Access 2003.
Bare with me on this description....here's the situation: Imagine insurance,
and working out premiums for different insured properties. The rates for
calculating...
|
by: ecoulson123 |
last post by:
I am using Access 2000. I am trying to summarize numeric data from a
large database. The problem is that I need the summarization functions
to ignore "junk" data, defined in a couple ways.
...
|
by: salad |
last post by:
I'm curious about your opinion on setting relationships.
When I designed my first app in Access I'd go to Tools/Relationships and
set the relationships. Over time I'd go into the window and see...
|
by: forbes |
last post by:
Hi,
I have a user that used the Query Wizard to create a query in Access.
Now she claims that her master table is missing all the data that was
excluded from the query. Can you create anything...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |