Jump to content

Recommended Posts

I have a query that takes between 6 - 9 seconds... I know this is because of poor design, but I am in a time crunch and need to figure out why asap....  Below is the query, any help would be very much appreciated!!!!

 

select services.claimno, issues.enduserfname, issues.enduserlname, services.servicetobedone, issues.status, issues.rescode, services.svcenterdate from services, issues where serviceid IN (select max(services.serviceid) from services where services.claimno = issues.claimno) and issues.rep_id="******" and issues.status != 'closed' and issues.status != 'Declined' order by serviceid desc;

 

here is the explain...

 

+----+--------------------+----------+------+---------------+------+---------+------+------+----------------------------------------------+

| id | select_type        | table    | type | possible_keys | key  | key_len | ref  | rows | Extra                                        |

+----+--------------------+----------+------+---------------+------+---------+------+------+----------------------------------------------+

|  1 | PRIMARY            | issues  | ALL  | NULL          | NULL | NULL    | NULL |  65 | Using where; Using temporary; Using filesort |

|  1 | PRIMARY            | services | ALL  | NULL          | NULL | NULL    | NULL |  509 | Using where                                  |

|  2 | DEPENDENT SUBQUERY | services | ALL  | NULL          | NULL | NULL    | NULL |  509 | Using where                                  |

+----+--------------------+----------+------+---------------+------+---------+------+------+----------------------------------------------+

3 rows in set (0.00 sec)

 

 

Thanks

Tom

Link to comment
https://forums.phpfreaks.com/topic/98335-newbie-help-with-slow-query/
Share on other sites

no indexes yet... I am REALLY REALLY new to the sql programming and started a project that has grown and grown and I think  am a little over my head....  Would you recommendations be to add indexs to both the services and issues tables, for the claimno, serviceid and rep_id columns?

 

Tom

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.