[wp-hackers] Optimize Post Meta Query

Beau Lebens beau at dentedreality.com.au
Wed Apr 29 22:14:18 GMT 2009


Just as an experiment off the top of my head, is it any faster if you
change it to this?

SELECT meta_key
FROM wp_postmeta
WHERE LEFT(meta_key, 1) != '_'
GROUP BY meta_key
ORDER BY meta_id DESC
LIMIT 30

Beau


On Wed, Apr 29, 2009 at 3:10 PM, Dan Fellars <danf at eliresearch.com> wrote:
> I use the postmeta table pretty extensively for CMS-like capabilities  (
> I have over 200k postmeta rows ).  In trying to find the culprit that is
> causing a long load time on edit post pages, (using sqlmon plugin), I
> found it all comes down to a single query - that I've seen take 10+
> seconds to return  (even when I run it in a database client outside of
> wp ):
>
>
>
> SELECT meta_key
> FROM wp_postmeta
> WHERE meta_key NOT LIKE '\_%'
> GROUP BY meta_key
> ORDER BY meta_id DESC
> LIMIT 30
>
>
>
> Any ideas on how to optimize this query?  Or am I relying too much on
> postmeta?  It already has an index on the meta_key field.  I've seen
> this behavior on 2 different systems.  I have mysql query_cache_size
> turned on, so I would think this query would get cached, but it doesn't
> appear to be.
>
>
>
>
>
> Thanks,
>
> Dan
>
>
>
>
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>



-- 
Beau Lebens
Dented Reality
beau at dentedreality.com.au
http://dentedreality.com.au


More information about the wp-hackers mailing list