Alter views limit using hook_views_query_alter I've used display specified number of items for set limit in views.
I want to change limit and also display all items using hook_views_query_alter().
I've tried this:

function test_views_query_alter(&amp;$view, &amp;$query) {
  if ($view-&gt;name == 'sample') {
    $query-&gt;set_limit(20);
    //~ $view-&gt;set_items_per_page(20);
  }
}


But i've no luck. How to solve this?
Try using the following:

function YOUR_MODULE_NAME_views_query_alter(&amp;$view, &amp;$query) { 
    $view-&gt;set_items_per_page(2);     
}