Re iTunes does it that way:
iTunes doesn’t use a sql backend. It only recalculates smart playlists whenever songs are added, so it can keep a running count of the number of songs in each playlist. I can’t do that.
As I said, we’ll see. Depends on if I can do it efficiently or not.