[wp-hackers] Restructuring Category Hierarchy

Jamie Talbot wphackers at jamietalbot.com
Tue May 8 01:26:42 GMT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Otto wrote:
> Took me a while to figure out just what the hell you were talking
> about, but I get it now. You're basically talking about hierarchy in
> the categories. And you're right, that is a more efficient way to do a
> tree model. Selection of a whole branch basically becomes a simple
> query. You get the left and right values of the category you want,
> then select everything with left/right values between those two
> values. Voila, you have all the children. The cost is that inserting a
> category into the hierarchy requires an insert and 2 updates, while
> deleting takes a delete and 3 updates. Not a huge deal, really.
>
> The one thing that does concern me on that dev.mysql page is that they
> talk about inserts and deletes, but they don't talk about rearranging
> the hierarchy. A rearrangement is basically a delete followed by an
> insert to another location, so you're looking at least 7 queries to do
> it in the most obvious way. That seems really high.

Though there may be a more optimised implementation than 7 queries, you're right that it is more
complex.  However, I can't see this being a well-used feature in any case - I mean, I can see it for
 making corrections, but not more than a few times.  Besides, if you call the process 'restructure
category tree', or something, people will expect it to take a while.  After all of which, we're
still talking varying degrees of milliseconds.

It definitely will be slower to insert into this model than the existing one.  But, it definitely
will be much quicker to select from it.  That's the kind of model I'd prefer for a critical part of
the system, which is interacted with on pretty much every page load.

Does anyone have real-world experience with this kind of technique, who can provide more insight?
I'm still very keen to see this implemented.  What do core devs think of this?

Cheers,

Jamie.

- --
http://jamietalbot.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGP9HSrovxfShShFARAoHkAJ9m4SEfchebGdfTAmgmz76UcU3OBgCfS/0a
SHc4nyU1QWr6MCsajkd13/U=
=fDk3
-----END PGP SIGNATURE-----


More information about the wp-hackers mailing list