Databases Reference
In-Depth Information
By looking at the histogram, you can find the value 434 on
EQ_ROWS
for the
RANGE_HI_
KEY
value "London."
Now run the following
UPDATE
STATISTICS
WITH
ROWCOUNT,
PAGECOUNT
statement
(you can specify any other value for
ROWCOUNT
and
PAGECOUNT
):
UPDATE
STATISTICS
dbo
.
Address
WITH
ROWCOUNT
=
1000000
,
PAGECOUNT
=
100000
Listing 3-55.
If you inspect the number of rows from
sys.partitions
or
sys.dm_db_parti-
tion_stats
again, as shown previously, it will now show 1,000,000 rows (
sys.dm_db_
partition_stats
also shows the new number of pages). Clear the plan cache and run
the query again.
DBCC
FREEPROCCACHE
GO
SELECT
*
FROM
dbo
.
Address
WHERE
City
=
'London'
Listing 3-56.
Note that the estimated number of rows has changed from 434 to 22,127.1, as shown on
Figure 3-14, and that a different plan was generated using this new cardinality estimation;
this time, the Query Optimizer decided to create a parallel plan.