[nycphp-talk] MySQL help
Brian Kaney
brian at vermonster.com
Thu Oct 21 17:45:54 EDT 2004
Hi Stephen,
Try running EXPLAIN on your statement and post the results.
http://dev.mysql.com/doc/mysql/en/EXPLAIN.html
Likely you may not be using indexs or keys most efficiently.
- Brian
On Thu, 2004-10-21 at 17:41, Stephen Musgrave wrote:
> So, I thought this query would be easy, but I've spent the better part
> of an afternoon on it. To put it mildly: it's very slow. Any tips on
> how i might speed it up would be greatly appreciated.
>
> SELECT
> a.column1
> COUNT(DISTINCT c.column1) as column1_count
> FROM
> table1 a,
> table2 b,
> table3 d,
> table4 h
> WHERE
> a.column2 = 1 AND a.column3 = 1
> AND (c.column3 = a.column3 AND c.column2 = a.column2)
> AND (d.column3 = a.column3 AND d.column2 = a.column2)
> AND (h.column3 = a.column3 AND h.column2 = a.column2)
> GROUP BY
> a. column3
> HAVING
> (column1_count >= 2)
>
> Thanks,
>
> Stephen
>
> _______________________________________________
> New York PHP Talk
> Supporting AMP Technology (Apache/MySQL/PHP)
> http://lists.nyphp.org/mailman/listinfo/talk
> http://www.newyorkphp.org
More information about the talk
mailing list