mysql select query optimization..


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users mysql select query optimization..
# 1  
Old 02-12-2011
mysql select query optimization..

hi..
i need to optimize my select query ..

my situation is like this ..
i have 15 lac recors in my table..
the following query takes nine seconds to give the required output..
Code:
SELECT max(ah.AUC_AMT),
SUBSTRING_INDEX(GROUP_CONCAT(SUBSTRING_INDEX(ah.AUC_CUS_NAME,'@',1) order by AUC_AMT DESC SEPARATOR '|_|'),'|_|',3), 
timediff(av.AUC_END_TIM,time(now())) as RemTime, 
av.AUC_END_TIM,av.AUC_RSV_PRC,av.AUC_DATE,av.AUC_STATUS 
from auc_hist_tbl as ah, aucveh_sched_tbl as av 
where ah.AUC_UNI_NO = '' 
AND av.AUC_UNI_NO = ''

auc_hist_tbl has 15 lac records ... i have indexed AUC_UNI_NO ..
but still its taking time ..
can u guide where's my query going wrong..
thanks ..

Last edited by Scott; 02-12-2011 at 04:58 AM.. Reason: Code tags, PLEASE...
# 2  
Old 02-13-2011
Are you sure you don't need a join?

Code:
where ah.AUC_UNI_NO = av.AUC_UNI_NO
and ah.AUC_UNI_NO = ''

Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Programming

MySQL select user with the same IP address

Dear community, I woul like to make a query to output all the users having the same IP address. The table is somethig like: name logged_ip ==== ========= user1 127.0.0.1 user2 127.0.0.2 user3 127.0.0.3 user4 127.0.0.1 user5 127.0.0.2 user6 127.0.0.5I used this query... (4 Replies)
Discussion started by: Lord Spectre
4 Replies

2. UNIX and Linux Applications

MySQL optimization or why the server is worsened

Hello Please advise me how can I optimize my MySQL server. Or advise which way to look. Maybe someone had similar problems? Over the past two weeks the MySQL server dropped 2 times. I began searching for ways to optimize the server. Overall the picture like that: There is a separate... (2 Replies)
Discussion started by: sergibondarenko
2 Replies

3. Shell Programming and Scripting

mysql select query optimization..

hi.. i need to optimize my select query .. my situation is like this .. i have 15 lac recors in my table.. the following query takes nine seconds to give the required output.. SELECT max(ah.AUC_AMT), SUBSTRING_INDEX(GROUP_CONCAT(SUBSTRING_INDEX(ah.AUC_CUS_NAME,'@',1) order by AUC_AMT... (0 Replies)
Discussion started by: senkerth
0 Replies

4. Shell Programming and Scripting

mysql how to select a specific row from a table

i have a table records ------------ id | user | time | event 91 admin | 12:00 | hi 92 admin | 11:00 | hi 93 admin | 12:00 | bye 94 admin | 13:00 | bye 95 root | 12:00 | hi 96 root | 12:30 | hi 97 root | 12:56 | hi how could i only select and display only the user and event from... (6 Replies)
Discussion started by: kpddong
6 Replies

5. Shell Programming and Scripting

Select record with MAX value in MySQL

Hi there, I have trouble selecting record that contain one biggest value for a group of other values. I mean, this is my table: mysql> SELECT * FROM b; +----+------+-------+ | id | user | value | +----+------+-------+ | 1 | 1 | 100 | | 3 | 1 | 150 | | 5 | 1 | 300 | | 6... (20 Replies)
Discussion started by: chebarbudo
20 Replies

6. Shell Programming and Scripting

Select query implement in a shell

I have been asked to create a shell script that accepts a number of SQL select queries as input, runs them in sequence, spools the output to an EXCEL workbook, where, each worksheet is an output of a Select statement run above. The workbook should be in a .XLS format. If a particular select... (2 Replies)
Discussion started by: ShellNovice1
2 Replies

7. Programming

Select several minimum values from row (MySQL)

Hello there. I've got the query like that SELECT count(tour_id) AS cnt FROM orders JOIN tours ON orders.tour_id=tours.id GROUP BY tour_id The result Is cnt 1 4 2 1 1 Now i have to select all records with minimum values in field "cnt" MySQL function min() returns only one.... (2 Replies)
Discussion started by: Trump
2 Replies

8. Shell Programming and Scripting

Need Help (Select query)

Dear All, This may sound a simple query but a non technical person like me is not able to do it, So please help me out. I m using Unix... isql I jst wanted to do something like following select * from xyz where ID= xxxxxxxx (8 digit ID) Here if i put single 8 digit ID then the... (5 Replies)
Discussion started by: topgear1000cc
5 Replies
Login or Register to Ask a Question