Posts

Showing posts from August, 2020

Creating Ghost Table, A blank table with phantom records

Image
  SQL server pretty much depends upon the statistics it collects  for the data objects, Statistics of a data object has major say  in the way sql designs plans and handles execution This gives us the loop hole in tricking the relational  engine/Query processor into designing query plan depending  upon the statistics which we alter. Sql server allows updating statistics manually, in this blog we  are going to trick relational engine into thinking a newly  created table and its effect on execution plans. UPDATE STATISTICS <table_name> WITH ROWCOUNT=50000, PAGECOUNT=24000; the above query of  UPDATE STATISTICS using option of  ROWCOUNT and PAGECOUNT enables us to manually set the  row count of table without having actual rows inserted, the  optimizer will not just look for the rows but also the amount  of pages that it needs to read to get the data hence the PAGECOUNT  lets implement it to a basic table : The stati...