PageSize

Table of Contents

Overview
The PageSize setting is used when creating a schema to define the number of document that will be stored in a single page. This setting can be changed at any time on a schema and will affect the ongoing sotrage but changing the setting will not rebuild the schema. If you wish to change the PageSize and have it affect existing data then you will need to reinsert the data.

The documents in a schema are stored in pages, each page is an individual file and defines the smallest read unit for a schema. When a query is executed, even if only one document is needed - the entire page must be read into memory, therfore larger page sizes can generally reduce I/O and memory consumption. Furthermore, read and write locks are added at the page level as well, so higher page sizes can drastically recude lock contention.

Unlike index Partitions, schemas can become somewhat fragmented over time but this does not generally affect performance.
When rows are inserted, they are written to a page. When the page is full (the document counts reaches the configure PageSize), a new page will be created and the cycle continues. When documents are deleted, they are removed from the page and any new insertions will fill this gap.

Schema page size will need to be carefully determined by the engineer which is designing the data model as it is heavily dependent on read/write/delete ratio as well as the expected size of the documents contained in the schema.

Decreasing page size on existing schemas

If the page size is set on an existing schema to a lower number than is currently contained in the pages, then the pages become over 100% full. This is not a problem, it simply means that they will not accept additional rows unless existing data is deleted. New rows will simply be added to a new page.

Increasing page size on existing schemas

If the page size is set on an existing schema to a higher number than is currently contaned in the schema then new inserts will fill in the pages from the first page forward.


Example
round-pushpin Creates a new empty schema with a PageSize of 1,000.
CREATE SCHEMA WordList:Words WITH (PageSize = 1000)

round-pushpin Modifies an existing schema setting the PageSize to 1,000.
ALTER SCHEMA WordList:Words WITH (PageSize = 1000)

Related