title: drupal 8 pagination is not working for select query
body: <p>i have a drupal 8  select query which returns list of items , i want to add pagination to it , but the pager is coming in the node but it is not paging correctly it is showing all the results , here is my code</p>
  <pre><code>    $sql = &quot;SELECT nid FROM node WHERE type='used_item'&quot;;
          $item_nids= \Drupal::database()-&gt;query($sql)
                      -&gt;fetchAllAssoc('nid');
          $total=count($item_nids);
         $num_per_page='12';
      
          $pager = \Drupal::service('pager.manager')
            -&gt;createPager($total, $num_per_page);
          $page = $pager
            -&gt;getCurrentPage();
          
         
          // Load the item nodes from the list array.
          $item_nodes = Node::loadMultiple(array_keys($item_nids));
          // Build the items.
          $item_build = \Drupal::entityTypeManager()-&gt;getViewBuilder('node')- 
   &gt;viewMultiple($item_nodes, 'carousel_card');
      
          $build[] = [
            '#theme' =&gt; 'full_list',
            '#name' =&gt; $name,
            '#description' =&gt; $description,
            '#item_cards' =&gt; $item_build,
          ];
          $build[] = [
            '#type' =&gt; 'pager',
          ];
          return $build;
  </code></pre>
  <p>please let me know if i am doing anything wrong .</p>