Get pages by template in WordPress

I’d originally posted this on the WordPress StackExchange site, but thought I’d share it here as well. If you ever need to get pages which use a certain template, you can use the following query. You can then use the loop as normal to iterate over the pages, as well as expanding on the above query, such as setting the order.

query_posts(array(
	'post_type' =>'page',
	'meta_key'  =>'_wp_page_template',
	'meta_value'=>'page-portfolio.php',
));

It may have once been useful to be able to just specify the page template in the query with an additional parameter, but I feel the widespread need for this is now gone, as many cases which would use this can be done better using Custom Post Types and a custom archive page.