Home > database >  * * * * * * * * * * * * * * SQL Server the problem of the partition table * * * * * * * * * * * * *
* * * * * * * * * * * * * * SQL Server the problem of the partition table * * * * * * * * * * * * *

Time:11-14

Before no partition table, in order to reduce the number of single table records, we will the same table according to the year level split into different table, such as Sales record Sales into such
Sales_2020 Sales_2021, Sales_2022
When through the programming language query, the first to determine the need to query the target table name

When the assumption of after a partition table has the following table structure

The CREATE TABLE [dbo] [test] (
[id] int the DEFAULT 'NOT NULL,
[create_datetime] datetime NOT NULL,
[create_year] AS (datepart (year, [create_datetime])) PERSISTED NULL - deliberately redundant
)
ON (PRIMARY)
GO

The CREATE NONCLUSTERED INDEX [ix_test____create_year]
ON [dbo] [test] (
[create_year] ASC
)

Column the create_datetime application of partition function is divided in
Could you tell me when using the following query
Select * from test where create_year=2020;

Query engine will voluntarily to partition is 2020 logic in the table to query? Or is to improve the SQL statement, thanks

CodePudding user response:

Like you just find out the name of the table, you also need to this table query content,

CodePudding user response:

Select * from test where create_year=2020;
Query engine will be active to partition is 2020 logic in the table to query.

CodePudding user response:

Directly to the partition of 2020
  • Related