Q:

Altering "posts_per_page" for defaut loop

I am trying to alter posts_per_page value in default wordpress loop on-the-fly, not for a custom loop.
global $wp_query ;
// $wp_query->query_vars['posts_per_page'] = 1000 ;
$wp_query->set('posts_per_page',1000) ;
while ($wp_query->have_posts()) {
    $wp_query->the_post() ;
    // other operations
}

How to do that?

A:

As Tom said, that will never work, as the main query have already executed. The only way to achieve that is to alter the main query before it is executed.
There is a action hook for that, pre-get_posts and this is the correct method to alter the main query.
Example:
function wpse_custom_ppp( $query ) {
    if ( !is_admin() && $query->is_main_query() ) {
        $query->set( 'posts_per_page', '1000' );
    }
}
add_action( 'pre_get_posts', 'wpse_custom_ppp' );

You can use additional conditional tags to target specific pages

