473,387 Members | 1,890 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,387 software developers and data experts.

How can I make this query more optimised?

Greetings

I have a table with the following table structure -

mysql> desc email_table;
+---------+---------------+-------------------+------+-----+---------+-------+
| Field | Type | Collation | Null |
Key | Default | Extra |
+---------+---------------+-------------------+------+-----+---------+-------+
| email | varchar(50) | latin1_swedish_ci | |
PRI | | |
| is_sent | enum('Y','N') | latin1_swedish_ci | YES |
| NULL | |
| id | int(10) | binary | |
PRI | 0 | |
+---------+---------------+-------------------+------+-----+---------+-------+

I have a index on (id,email)....

I do a query like with Explain...

explain select

concat(sum(conv(substring(md5(concat(email,is_sent ,id)),1,8),16,10)),
sum(conv(substring(md5(concat(email,is_sent,id)),9 ,8),16,10)))
as b,
substring(concat(id,email),1,3) as c,
count(*) as cnt from test.email_table
where substring(concat(id,email),1,2) = '33'
group by substring(concat(id,email),1,3)
order by 1;

+----+-------------+-------------+------+---------------+------+---------+------
+-------+----------------------------------------------+
| id | select_type | table | type |
possible_keys | key | key_len | ref
| rows | Extra
|
+----+-------------+-------------+------+---------------+------+---------+------
+-------+----------------------------------------------+
| 1 | SIMPLE | email_table | ALL | NULL
| NULL | NULL | NULL
| 33914 | Using where; Using temporary; Using filesort
|
+----+-------------+-------------+------+---------------+------+---------+------
+-------+----------------------------------------------+

The Explain says that it is not using any query and
scanning 33914 rows ( that is the number of rows in my
table ).

When I execute the query, it takes around 80ms,
returns 10 rows. I am running MySQL 4.1.0-alpha-max-nt
on WinXP.

Is there any way to optimise this query more.....or
the time taken by MySQL is GOOD?

Thanks in advance.

karam

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/my***********...ie.nctu.edu.tw

Jul 19 '05 #1
0 1226

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

Similar topics

0
by: Karam Chand | last post by:
Greetings I have a table with the following table structure - mysql> desc email_table; +---------+---------------+-------------------+------+-----+---------+-------+ | Field | Type ...
1
by: mark | r | last post by:
anyone know a tutorial or sample code for uploading an image to a web server and optimising it and saving the optimised file to a folder? also can you mix .net and regular asp on the same page? ...
19
by: Andy B | last post by:
Hello, Sorry for this newbish question. Briefly, my problem: ------------------ I expect the database I'm working on to reach something in the order of 12-16 Gigabytes, and I am interested...
3
by: Tom Padilla | last post by:
I am making a map generator and for some bizarre reason I have a variable that will not come in scope. Code snippet: void placeContinents(int NumberOfContinents) { for(int Loop = 0; Loop <...
9
by: Gregory Petrosyan | last post by:
Hello, it's me again. I am trying to optimise small module for working with polynomials, and I have encountered problem: new, optimised, code, doesn't work in some specific case. Here's the old...
5
by: - | last post by:
I have only 1m records in my database running on a laptop of speed 1.6GHz, memory 512MB ram, and Toshiba MK8032GAX hard disk. I use 'LIMIT x,10' for the query to utilise record paging. When the...
75
by: At_sea_with_C | last post by:
Hello all, I have written an ascending sort routine for floats. This seems to do the job, but for elements over 10,000, it gets awfully slow. A lot of useless comparisions with previously sorted...
15
by: karthikbalaguru | last post by:
I came across a nice example and info that claim that ++x is optimised than x++. Is it so ? For example. for(x = 0; x < 10; x++) There is a simple fix for this, and it will optimize your loop,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.