473,385 Members | 2,069 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Does my query look good?

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

Jul 23 '05 #1
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;
Jul 23 '05 #2
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.
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
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....
29
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"...
3
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...
4
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...
9
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...
4
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...
2
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. ...
45
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...
13
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...
0
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
0
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
1
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...
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
jinu1996
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.