Setting posts per page in query_posts

Here’s what I usually use the pre_get_posts action to change a single query value for a taxonomy or category page:

/**
 * Control the number of search results
 */
function custom_posts_per_page( $query ) {
    if ( $query->is_tax('mytaxonomy') || $query->is_category('mycategory') ) {
        set_query_var('posts_per_page', 9);
    }
}
add_action( 'pre_get_posts', 'custom_posts_per_page' );