title: When to specify PagingInfo.PagingCookie and PagingInfo.PageNumber
body: <p>Though reading lots of available resources online, I couldn't find a straight explanation that clarifies: </p>
  
  <p><strong>In what case both the values of <code>PageingInfo.PageNumber</code> and <code>PageingInfo.PagingCookie</code> are required to be assigned?</strong></p>
  
  <p>For example: Consider we have 10,000 unique records, and we'd like to retrieve all of them, but 200 records at a time. <strong>Do we have to iterate over <code>PageNumber</code> (50 iterations), or is it enough to use only the <code>PagingCookie</code>?</strong></p>
  
  <p>Now, I'd like to share what I've found on online resources: </p>
  
  <p>Firstly, many online resources links to the official MSDN examples (For FetchXML: <a href="https://msdn.microsoft.com/en-us/library/gg328046.aspx" rel="nofollow noreferrer">1</a>, <a href="https://msdn.microsoft.com/en-us/library/gg309717.aspx" rel="nofollow noreferrer">2</a>, for QueryExpression: <a href="https://msdn.microsoft.com/en-us/library/mt269606.aspx" rel="nofollow noreferrer">1</a>, <a href="https://msdn.microsoft.com/en-us/library/gg327917.aspx" rel="nofollow noreferrer">2</a>), but there isn't a direct answer for this issue. They all iterate over the <code>PageNumber</code>, but as I understand (and it may be wrong), a Page <em>always</em> has 5000 records (Or is it?).</p>
  
  <p>Secondly, I've found <a href="https://truenorthit.co.uk/2014/07/19/dynamics-crm-paging-cookies-some-gotchas/" rel="nofollow noreferrer">this</a> demonstration of using <code>PagingCookie</code>, fetching <em>records 6-10 out of 40 records</em>:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;fetch mapping="logical" count="5" page="2" paging-cookie="&amp;lt;cookie page=&amp;quot;1&amp;quot;&amp;gt;&amp;lt;new_parentrecordid last=&amp;quot;{F8DAB1AA-3A0F-E411-8189-005056B20097}&amp;quot; first=&amp;quot;{F8DAB1AA-3A0F-E411-8189-005056B20097}&amp;quot; /&amp;gt;&amp;lt;/cookie&amp;gt;" version="1.0"&gt;
      &lt;entity name="new_parentrecord"&gt;
          &lt;attribute name="new_name" /&gt;
          &lt;link-entity name="new_childrecord" from="new_parentaid" to="new_parentrecordid"&gt;
              &lt;attribute name="new_childrecordid" /&gt;
              &lt;attribute name="new_name" /&gt;
          &lt;/link-entity&gt;
      &lt;/entity&gt;
  &lt;/fetch&gt;
  </code></pre>
  
  <p>Then, it's explained that the above is translated to the following SQL query:</p>
  
  <pre class="lang-sql prettyprint-override"><code>select top 6 "new_parentrecord0".new_name as "new_name"
              , "new_parentrecord0".new_parentrecordId as "new_parentrecordid"
              , "new_childrecord1".new_childrecordId as "new_childrecord1.new_childrecordid"
              , "new_childrecord1".new_name as "new_childrecord1.new_name" 
  from
       new_parentrecord as "new_parentrecord0" 
      join new_childrecord as "new_childrecord1" on ("new_parentrecord0".new_parentrecordId  =  "new_childrecord1".new_ParentAId) 
  where
       ((("new_parentrecord0".new_parentrecordId &gt; '01DBB1AA-3A0F-E411-8189-005056B20097'))) 
  order by
       "new_parentrecord0".new_parentrecordId asc
  </code></pre>
  
  <p>Thus, as I see it in this example, <em>there is no need to use the page number, since only the paging cookie is being used in resulted the SQL query</em>.</p>
  
  <p>Would be great to have a nice clarification for this issue.</p>