问题描述
目标:
推荐和最佳的源代码实践,以便进行良好的性能调整。
Goal:
Recommended and best of practice of the source code in order to have a good performance tuning.
问题:
我不知道此代码是否是与性能相关的推荐方法。
它可能比下面的源代码更好的解决方案
Problem:
I do not know if this code is the recommended approach in relation to performance.
It might a better solution than this source code below
需要考虑的一些问题:
Enduser 1想要检索整个数据和标准(其中st atement)是活动的(isactive = 1)
Enduser 2希望整个数据符合条件(where语句)databaseint(1和2)和countryid(1到10)
Enduser 3希望数据符合条件(where语句)countryid(1和2),isactive(1),location(1-3)和categoryid(1)
等......
等......
等......
Some questions to take account to:
Enduser 1 wants to retrieve the whole data and the criteria(where statement) is active (isactive=1)
Enduser 2 wants the whole data with criteria(where statement) databaseint(1 and 2) and countryid(1 to 10)
Enduser 3 wants the data with criteria(where statement) countryid(1 and 2), isactive(1), location(1-3) and categoryid(1)
etc...
etc...
etc...
你可能会理解有许多不同的队列有不同的标准(where语句)。
You might understand that there are many and different quetions with different criteria(where statement).
主要问题是:
建议使用什么样的存储过程T-SQL代码,以便按顺序填写所有不同的问题及其标准有一个很好的性能调整?
The main question is:
What T-SQL code for the stored procedure is recommended in order to fullfill all the different questions and its criteria in order to have a good performance tuning?
信息:
*使用SQL Server 2018
*我只有源代码而不是数据。
* Ecommence网站有一个标准列表,例如购买一台电脑:多少内存,选择多个或单个处理器,品牌等。
Information:
*Using SQL server 2018
*I only have the sourcecode but not the data.
*Ecommence website have a criteria list for instance buying a computer: how much memory, select many or single processor, brand etc.
谢谢!
---------------
---------------
桌上人物
personid(int)
countryid(int)
firstname(nvarchar(50))
lastname(nvarchar(50))
age(int)
isactive(位)
databaseid(int)
locationid(id)
categoryid (int)
table person
personid(int)
countryid(int)
firstname(nvarchar(50))
lastname(nvarchar(50))
age(int)
isactive(bit)
databaseid(int)
locationid(id)
categoryid(int)
表格中总计10万行。
countryid =共30个不同的身份
isactive =只有1或0
databaseid =共6个不同的id
categoryid =共4个不同的id
locationid =完全5个不同的id
It is totallt 100 000 row in the table person.
countryid = totally 30 different id
isactive = only 1 or 0
databaseid = totally 6 different id
categoryid = totally 4 different id
locationid = totally 5 different id
--------
--------
表格中总计10万行。
countryid =共30个不同的身份
isactive =只有1或0
databaseid =共6个不同的id
categoryid =共4个不同的id
locationid =完全5个不同的id
It is totallt 100 000 row in the table person.
countryid = totally 30 different id
isactive = only 1 or 0
databaseid = totally 6 different id
categoryid = totally 4 different id
locationid = totally 5 different id
-----------------
-----------------
创建表[dbo]。[person](
[personid] [int] NOT NULL,
[countryid] [int] NOT NULL,
[firstname] [nvarchar](50)NOT NULL,
[lastname] [nvarchar](50)NOT NULL,
[age] [int] NOT NULL,
[isactive] [bit] NOT NOT NULL,b
[databaseid] [int] NOT NULL,
[categoryid] [int] NOT NULL
)ON [PRIMARY]
GO
CREATE TABLE [dbo].[person](
[personid] [int] NOT NULL,
[countryid] [int] NOT NULL,
[firstname] [nvarchar](50) NOT NULL,
[lastname] [nvarchar](50) NOT NULL,
[age] [int] NOT NULL,
[isactive] [bit] NOT NULL,
[databaseid] [int] NOT NULL,
[categoryid] [int] NOT NULL
) ON [PRIMARY]
GO
推荐答案
这篇关于增加Where语句的性能调优的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!