views:

31

answers:

1

EDITED: so the query does work, but on my localhost machine it took over a minute to run. Admittedly the tables are considerably larger on my localhost (about 8000 rows each), but in production the tables could have upwards of 25,000 rows each. Is there any way to optimize this so it doesn't take as long? As indicated in one of the comments, both tables are indexed.

I have two tables, jos_eimcart_customers_addresses and jos_eimcart_customers. I want to pull all records from the customers table, and include address information where available from the addresses table. I have what I thought was a fairly ordinary left outer join query, but it keeps timing out in phpMyAdmin, even though there aren't that many results it should be finding. Can anyone point out if I'm doing something wrong? I'm not getting a mySQL error.

select 
    c.firstname,
    c.lastname,
    c.email as customer_email, 
    a.email as address_email,
    c.phone as customer_phone,
    a.phone as address_phone,
    a.company,
    a.address1,
    a.address2,
    a.city,
    a.state,a.zip, 
    c.last_signin
from jos_eimcart_customers c
    left outer join  jos_eimcart_customers_addresses a  
    on c.id = a.customer_id  
order by c.last_signin desc
A: 

There is nothing wrong with your query (assuming the counts are as you say they are). Something else is going on in your server.

Any chance it is waiting on a lock?

Nix
I don't think so; how would I find out?
EmmyS
Run a "show process list" while it's running.You can see what your query is doing (sending data, locked, etc).
ceteras
I don't think I can do that in phpMyAdmin, which is the only access I have to the server.
EmmyS
Ask your DBA to pull the info on what is going on, on the server while your query is running. He will know what to do...
Nix