• Digging Into WordPress Book

5 Comments

  1. Alex alexking.org
    Posted February 26, 2004 at 5:52 pm | Permalink

    Dougal, are you using a serialized array/object for the meta?

  2. Dougal dougal.gunters.org
    Posted February 27, 2004 at 8:54 am | Permalink

    I’ve added a new wp_postmeta database table. The structure is simple, just four fields: meta_id, post_id, meta_key, meta_value. The tricky part was converting that flat structure into a hierarchical struct. I build a $post_meta_cache object in wp-blog-header.php which contains the metadata for the currently selected set of posts. That way, each page view only requires one extra query to fetch the metadata.

  3. Alex alexking.org
    Posted February 27, 2004 at 6:26 pm | Permalink

    Was there a reason you decided not get it in the same query with a LEFT JOIN?

  4. Alex alexking.org
    Posted February 28, 2004 at 11:59 am | Permalink

    Oops, sorry was still stuck in my serialized thought process, a JOIN probably wouldn’t work well since there is a one to many relationship there.

  5. Dougal dougal.gunters.org
    Posted March 1, 2004 at 2:28 pm | Permalink

    Yeah, I almost started to do a join, but I quickly saw that it was going go get really messy trying to do it that way. That’s why I switched to just building a ‘cache’ variable with the metadata for the currently selected set of posts.

    It’s only one extra query per page load, so it shouldn’t be a big deal. I just have to wonder how well optimized MySQL’s IN clause is when the $post_id_list gets big.

Post a Comment

Your email is never published nor shared.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe without commenting