Home > database >  ===========SQL Server partition table problem===================
===========SQL Server partition table problem===================

Time:11-18

Only take you 2 minutes time, thank you,,,,

Create table test
(
Id int the not null,
Create_datetime datetime not null,
Create_year AS (datepart (year, create_datetime) PERSISTED,
);

The create index ix_test____create_year on dbo. Test
(
Create_year asc
);

Insert into test values (' 2020-6-4 '), (' 2020-6-8 '), (' 2020-12-31 '), (' 2021-5-8 ');

- the above table among the create_datetime partition function on the application of the divisions, according to the
- now to ask for all data in 2020, could you tell me the following query can make full use of the advantages of the partition table or said below I write is not correct, thank you,,, thank you,,,

- select * from test where year (create_datetime)=2020;
- select * from test where create_year=2020;

CodePudding user response:

 
Select * from test where create_year=2020

CodePudding user response:

The
reference 1/f, started the first reply:
 
Select * from test where create_year=2020


Thank moderator reply, I know too little about the partition table, give you this, not on the partitioning column query it won't hit partition data is located? Isn't this supposed to be not very efficient?

CodePudding user response:

Should be avoided, in general, a reading for a whole year of data, and take all the fields. Such a large amount of data to the front end is inappropriate.

CodePudding user response:

reference 3 floor started the first response:
normally, should avoid a reading for a whole year data, and take all the fields. Such a large amount of data to the front end is inappropriate.


Thanks to the moderator, I ask this question method has a problem, I opened a post again, look at the trouble thank you

https://bbs.csdn.net/topics/396806532
  • Related