You have written the following:
[snip & arrange]
SELECT idemailsent,
email,
idclient
FROM wmkt_email_sent a,
wmkt_client b,
wmkt_email c
WHERE nMachine = 0
AND c.idemail=a.fkemail
AND b.fkemail=a.fkemail
AND fkuser=1
AND fkpbl=23
ORDER BY email
LIMIT 1000
[/snip]
Shouldn't it be SELECT a.idemailsent, c.email, b.idclient and WHERE
a.nMachine = 0 (I am being slightly picky here, but alias' are there for a
reason). Also, it looks like your AND's should be something like
AND c.idemail=b.fkemail
AND b.fkemail=a.fkemail
note the order of processing. You didn't say how many total records. Can you
do this;
EXPLAIN SELECT a.idemailsent, c.email, b.idclient
FROM wmkt_email_sent a, wmkt_client b, wmkt_email c
WHERE a.nMachine = 0
AND c.idemail=a.fkemail
AND b.fkemail=a.fkemail
AND b.fkuser=1
AND a.fkpbl=23
ORDER BY c.email
LIMIT 1000
and mail thos results back?
Plus, I would re-arrange the query, putting conditions with values ahead of
conditions
with matches and move from left to right in the table order;
EXPLAIN SELECT a.idemailsent, c.email, b.idclient
FROM wmkt_email_sent a, wmkt_client b, wmkt_email c
WHERE a.nMachine = 0
AND a.fkpbl=23
AND b.fkuser=1
AND a.fkemail=b.fkemail
AND b.fkemail=c.idemail
ORDER BY c.email
LIMIT 1000
Looks like you can use a couple of things....denormalization and INDEXES.
HTH!
Jay
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php