Hi,
Thank u very much!! It helped a lot... I also created two indexes: one in
wmkt_email_sent for (nmachine e fkpbl) and another in wmkt_client for
fkEmail (both sugested by Luciano Barcaro).
About the size of the resultset: all these table have about 100.000 records
and they can be about 10.000.000 (in the end of this year). So if u have
more ideas, i'll be very grateful.

Thank u very much,
Edilson.


-----Mensagem original-----
De: Jay Blanchard [mailto:[EMAIL PROTECTED]]
Enviada em: sexta-feira, 3 de maio de 2002 14:18
Para: 'MYSQL'
Assunto: RE: My Query is TOOOOOOOOOOOO Slow :(


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


---------------------------------------------------------------------
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

Reply via email to