Optimizing queries using partitioned views
Hello everyone!
partitioned views, like the shared tables in SQL Server 2005, are a simple way to distribute data on multiple FILEGROUPS to reduce maintenance costs. It is even possible with distributed partitioned views distribute the load, simply by storing different tables on different servers. Partitioned views
therefore include data from multiple tables whose structure is identical. Thus, all operations of insertion, modification and deletion can be performed on a partitioned view, subject to a condition sine qua non: the key to divide must be part of the primary key of each table aggregated. If
partitioned views are very commonly used to aggregate the data within data centers multisite, partitioned views are nonetheless the only way to horizontal partitioning on SQL Server 2000.
Therefore, these views prove to be unavoidable under SQL Server 2000 to architect a solution for high volume or have a sliding window of data - in this particular case, the key is commonly the date.
To better understand how to optimize a partitioned view, start with an example. Create two tables with the same structure.
CREATE TABLE TB1 (Id INT NOT NULL PRIMARY KEY CONSTRAINT PK_TB1, PartitionCol INT NOT NULL) CREATE TABLE
TB2 (Id INT NOT NULL PRIMARY KEY CONSTRAINT PK_TB2, PartitionCol INT NOT NULL)
Sight Next is the view then "partitioned" which allows to concatenate the data from these two tables: CREATE VIEW
VALL AS SELECT Id FROM TB1 PartitionCol UNION SELECT Id FROM TB2 PartitionCol
However, this view is far from For best performance, performing the same task of recognition in order to avoid duplication.
Suppose now that our data are distributed so distinct as the key. Then we can safely write:
VALL ALTER VIEW AS SELECT Id FROM TB1 PartitionCol UNION ALL SELECT Id FROM TB2 PartitionCol
This view is now significantly better, but still not very interesting.
now apply CHECK constraints type system to ensure the proper separation of data, such as separating the negative positive elements:
ALTER TABLE ADD CONSTRAINT TB1 CK_TB1_PartitionCol CHECK (PartitionCol < 0)
ALTER TABLE ADD CONSTRAINT CK_TB2_PartitionCol TB2 CHECK (PartitionCol> = 0)
By leveraging our view using the following command, we obtain finally the expected result:
SELECT Id, PartitionCol VALL FROM WHERE = 50 PartitionCol
Indeed, one can see the execution plan of our request that only the table TB2 is actually queried.
We can now proceed to the final step in optimizing our partitioned view. To do this we must add our allocation in the primary key. Thus, we can use our partitioned view to insert and modify our data.
ALTER TABLE DROP CONSTRAINT TB1 PK_TB1
ALTER TABLE ADD CONSTRAINT TB1 PK_TB1 PRIMARY KEY (Id, PartitionCol)
ALTER TABLE DROP CONSTRAINT TB2 PK_TB2
ALTER TABLE ADD CONSTRAINT TB2 PK_TB2 PRIMARY KEY (Id, PartitionCol)
command following is possible!
INSERT INTO VALL (Id, PartitionCol) VALUES (10, 1000)
I agree that these easily partitioned views have many difficulties in implementation, and that in matters of "sliding window", nothing beats partitioned tables in SQL Server 2005. However, it is an architecture in SQL Server 2000 or a distributed architecture across multiple servers, partitioned views prove to be a formidable weapon in the arsenal of Database Developer.
soon, and all your bench!
Monday, June 18, 2007
Thursday, May 31, 2007
Hiv Results After 7 Weeks
High Availability and licensing SQL Server 2005
Goodnight !
Until I find a way to publish a post close to my heart, I just tell you about a topic of interest at one time or another everyone: the sub!
Indeed, implementing a high availability solution is often seen by many clients as a financial position of the most expensive. I come here to remove these prejudices ... The licensing policy of SQL Server 2005 allows companies with limited financial means to obtain a robust solution at low cost. The first
prejudices that I would break it here, probably due to the reality of the previous version of SQL Server, is that SQL Server 2005 does not require the acquisition of a publishing company to help implement a high availability solution. Indeed, the Standard Edition supports solutions mirroring, clustering and log shipping ... And of course, the distribution of data!
The second aspect is a license that is often in my conversations with my clients: high availability solutions such as mirroring and clustering solutions are called "Passive-Active" - understand that the backup server is in position waiting and can not serve the user - Microsoft believes that you should not invest in a license for your server backup if it does not replace the primary server for more than 30 days a year!
course, there are limits, since, for example, mirroring proposed in the Standard Edition supports only two nodes at most 2 processors each ... But when we recall that the witness server can be realized by a simple SQL Server 2005 Express, it is clear that SQL Server 2005 provides a high availability solution fully accessible.
you soon!
Goodnight !
Until I find a way to publish a post close to my heart, I just tell you about a topic of interest at one time or another everyone: the sub!
Indeed, implementing a high availability solution is often seen by many clients as a financial position of the most expensive. I come here to remove these prejudices ... The licensing policy of SQL Server 2005 allows companies with limited financial means to obtain a robust solution at low cost. The first
prejudices that I would break it here, probably due to the reality of the previous version of SQL Server, is that SQL Server 2005 does not require the acquisition of a publishing company to help implement a high availability solution. Indeed, the Standard Edition supports solutions mirroring, clustering and log shipping ... And of course, the distribution of data!
The second aspect is a license that is often in my conversations with my clients: high availability solutions such as mirroring and clustering solutions are called "Passive-Active" - understand that the backup server is in position waiting and can not serve the user - Microsoft believes that you should not invest in a license for your server backup if it does not replace the primary server for more than 30 days a year!
course, there are limits, since, for example, mirroring proposed in the Standard Edition supports only two nodes at most 2 processors each ... But when we recall that the witness server can be realized by a simple SQL Server 2005 Express, it is clear that SQL Server 2005 provides a high availability solution fully accessible.
you soon!
Tuesday, May 22, 2007
Bumps On Inner Labia Normal Taste Bud
Stir reports in Reporting Services 2005 Web Application Maintenance
Hello everyone!
During the various workshops and training that I animated about Reporting Services 2005, a question comes up regularly : Interoperability.
Indeed, if Reporting Services is very well integrated in the world. Net, especially with the ReportViewer component, how can we integrate a report in a classic ASP page? Reporting Services how to fly from a single frame?
While integration of Reporting Services through the URL of the report server is relatively simple, it is however not the same for the settings to customize the display. And there are few elements of documentation available to us. I therefore propose here a selection of useful parameters for integrating Reporting Services reports in Web pages.
Create for example the report "My Rapport.rdl " which is stored in a new folder "Test " of our Reporting Services server.
In order to test all parameters, we add a parameter in our report called " DateDuJour .
By default, the URL http://localhost/reportserver? 2fTest%% + Report 2fMon allows me to get my report - of course starting from the premise that the report server is well in address http://localhost/reportserver and the Report Manager is located at http://localhost/Reports .
It is possible to prevent the user from having to enter the setting by adding the parameter in the URL:
http://localhost/reportserver? 2fTest%% + Report & 2fMon DateDuJour = 1.1 / 2007
However, the record still has got a heavy toolbar and allows the user to modify at will the report parameters.
There are actually many parameters to customize the display of our report. We distinguish two broad categories:
- server settings prefixed by the namespace rs,
- Parameters Rendering components prefixed by the namespace rc.
Here are the server settings the most useful:
- rs: Command
This parameter defines the action taken by the server. By default, the value of this parameter is set to "Render " for reports and " ListChildren " for folders.
There are also two other possible values for this parameter: " GetRessourceContents " and " GetDataSourceContents .
If you specify this parameter, the URL of our relationship becomes:
http://localhost/reportserver?%% 2fTest 2fMon + Report & rs: Command = Render & DateDuJour = 01/01/2007
- rs: Format
The format is undoubtedly one of the preferred settings for users. It allows to define the format of the report from existing formats ( HTML3.2 , HTML4.0 , HTMLOWC , MHTML, IMAGE , Excel, CSV , PDF , XML) or other extensions if they are available on the server.
So if you want to get our report in PDF, the URL of our relationship becomes:
http://localhost/reportserver?%% 2fTest 2fMon + Report & rs: Command = Render & rs: Format = PDF & DateDuJour = 01/01/2007
- rs: ParameterLanguage
This parameter allows to overcome the culture of the client browser by specifying a specific culture. The default is the value of the client browser.
example, we can force the culture of our report using the following URL:
http://localhost/reportserver?%% 2fTest 2fMon + Report & rs: Command = Render & rs: ParameterLanguage = en & DateDuJour = 01 / 01/2007
- rs: Snapshot
Parameter Snapshot allows you to use the capture of a report made at a time and one o'clock sharp. This snapshot is stored in the database Reporting Services.
This parameter receives a long time without timezone. Our URL is:
http://localhost/reportserver?%% 2fTest 2fMon + Report & rs: Command = Render & rs: Snapshot = 2007-05-22T15: 41:08
This parameter obviously requires that the history of the report be enabled.
- rs: ClearSession
this parameter to force the browser to clear its cache and reload a new version of the report.
In our case, the URL becomes:
http://localhost/reportserver?%% 2fTest 2fMon + Report & rs: Command = Render & rs: = true & ClearSession DateDuJour = 01/01/2007
- rs: SessionID
A parameter that identifies an active session when the report server does not use cookies.
The URL takes the following form:
http://localhost/reportserver?%% 2fTest 2fMon + Report & rs: Command = Render & rs: SessionID = uwoits45rufhhg55f2i3hm55 & DateDuJour = 01/01/2007
We will now consider some rendering parameters useful:
- rc: Toolbar
This setting allows you to display or hide the entire toolbar.
For example, if we want to hide Toolbar, our URL is:
http://localhost/reportserver?%% 2fTest 2fMon + Report & rs: Command = Render & rc: Toolbar = false & DateDuJour = 01/01/2007
value Default is obviously set to "true .
- rc: Parameters
This parameter does not hide the fact that the edition of the report parameters of the toolbar. The value of this parameter does not affect whether the precedent is set to "false .
So if we want the report parameters are fixed, our URL is:
http://localhost/reportserver?%% 2fTest 2fMon + Report & rs: Command = Render & rc: Parameters = false & DateDuJour = 01/01/2007
The default is obviously set to " true. "
- rc: Section
This parameter displays the report page you want. By default, Reporting Services displays the first page of the report.
To view the second page, we write:
http://localhost/reportserver?%% 2fTest 2fMon + Report & rs: Command = Render & rc: Section = 2 & DateDuJour = 01/01/2007
This parameter is particularly useful if one wishes to develop its own toolbar.
- rc: Zoom
It is a given parameter can be operated with versions of Internet Explorer 5.0 or later.
Possible values for this parameter are: *
" page + width" to occupy the entire width of the browser,
* "Whole + page" to maximize space in the browser to view the report on a single page
* an integer corresponding to a percentage, the default is "100 .
- rc: LinkTarget
Useful if your report contains hyperlinks, this parameter can specify the window frame or the destination of links in your report.
The possible values include: *
"_blank "
* "_self "
* "_parent "
* " _top"
* Or any other valid target name .
- rc: FindString, rc: StartFind, rc: EndFind
The parameter rc: FindString can filter the records of the report. This parameter is often used in conjunction with the parameters rc: StartFind and rc: EndFind that can confine the search.
For example, to search for the string "Test " in the first 2 pages of the report, the URL will be:
http://localhost/reportserver?%% 2fTest 2fMon + Report & rc: FindString = Test & rc: StartFind = 1 & rc: EndFind = 2 & DateDuJour = 01/01/2007
- rc: Stylesheet
The last parameter I will elaborate in this post can define a style sheet to apply the report.
The CSS must be present in the repertoire of styles, default
C: \\ Program Files \\ Microsoft SQL Server \\ MSSQL \\ Reporting Services \\ ReportServer \\ Styles
To apply the stylesheet " mystyle.css ", the URL becomes :
http://localhost/reportserver?%% 2fTest 2fMon + Report & rs: Command = Render & rc: Stylesheet = myStyle & DateDuJour = 01/01/2007
Note as the report's call for the absence of extension.
I will conclude by the fact that most of the parameters presented here are valid as service packs Reporting Services 2000, and therefore this section does not apply only to users of Reporting Services 2005 .
soon for another article!
Hello everyone!
During the various workshops and training that I animated about Reporting Services 2005, a question comes up regularly : Interoperability.
Indeed, if Reporting Services is very well integrated in the world. Net, especially with the ReportViewer component, how can we integrate a report in a classic ASP page? Reporting Services how to fly from a single frame?
While integration of Reporting Services through the URL of the report server is relatively simple, it is however not the same for the settings to customize the display. And there are few elements of documentation available to us. I therefore propose here a selection of useful parameters for integrating Reporting Services reports in Web pages.
Create for example the report "My Rapport.rdl " which is stored in a new folder "Test " of our Reporting Services server.
In order to test all parameters, we add a parameter in our report called " DateDuJour .
By default, the URL http://localhost/reportserver? 2fTest%% + Report 2fMon allows me to get my report - of course starting from the premise that the report server is well in address http://localhost/reportserver and the Report Manager is located at http://localhost/Reports .
It is possible to prevent the user from having to enter the setting by adding the parameter in the URL:
http://localhost/reportserver? 2fTest%% + Report & 2fMon DateDuJour = 1.1 / 2007
However, the record still has got a heavy toolbar and allows the user to modify at will the report parameters.
There are actually many parameters to customize the display of our report. We distinguish two broad categories:
- server settings prefixed by the namespace rs,
- Parameters Rendering components prefixed by the namespace rc.
Here are the server settings the most useful:
- rs: Command
This parameter defines the action taken by the server. By default, the value of this parameter is set to "Render " for reports and " ListChildren " for folders.
There are also two other possible values for this parameter: " GetRessourceContents " and " GetDataSourceContents .
If you specify this parameter, the URL of our relationship becomes:
http://localhost/reportserver?%% 2fTest 2fMon + Report & rs: Command = Render & DateDuJour = 01/01/2007
- rs: Format
The format is undoubtedly one of the preferred settings for users. It allows to define the format of the report from existing formats ( HTML3.2 , HTML4.0 , HTMLOWC , MHTML, IMAGE , Excel, CSV , PDF , XML) or other extensions if they are available on the server.
So if you want to get our report in PDF, the URL of our relationship becomes:
http://localhost/reportserver?%% 2fTest 2fMon + Report & rs: Command = Render & rs: Format = PDF & DateDuJour = 01/01/2007
- rs: ParameterLanguage
This parameter allows to overcome the culture of the client browser by specifying a specific culture. The default is the value of the client browser.
example, we can force the culture of our report using the following URL:
http://localhost/reportserver?%% 2fTest 2fMon + Report & rs: Command = Render & rs: ParameterLanguage = en & DateDuJour = 01 / 01/2007
- rs: Snapshot
Parameter Snapshot allows you to use the capture of a report made at a time and one o'clock sharp. This snapshot is stored in the database Reporting Services.
This parameter receives a long time without timezone. Our URL is:
http://localhost/reportserver?%% 2fTest 2fMon + Report & rs: Command = Render & rs: Snapshot = 2007-05-22T15: 41:08
This parameter obviously requires that the history of the report be enabled.
- rs: ClearSession
this parameter to force the browser to clear its cache and reload a new version of the report.
In our case, the URL becomes:
http://localhost/reportserver?%% 2fTest 2fMon + Report & rs: Command = Render & rs: = true & ClearSession DateDuJour = 01/01/2007
- rs: SessionID
A parameter that identifies an active session when the report server does not use cookies.
The URL takes the following form:
http://localhost/reportserver?%% 2fTest 2fMon + Report & rs: Command = Render & rs: SessionID = uwoits45rufhhg55f2i3hm55 & DateDuJour = 01/01/2007
We will now consider some rendering parameters useful:
- rc: Toolbar
This setting allows you to display or hide the entire toolbar.
For example, if we want to hide Toolbar, our URL is:
http://localhost/reportserver?%% 2fTest 2fMon + Report & rs: Command = Render & rc: Toolbar = false & DateDuJour = 01/01/2007
value Default is obviously set to "true .
- rc: Parameters
This parameter does not hide the fact that the edition of the report parameters of the toolbar. The value of this parameter does not affect whether the precedent is set to "false .
So if we want the report parameters are fixed, our URL is:
http://localhost/reportserver?%% 2fTest 2fMon + Report & rs: Command = Render & rc: Parameters = false & DateDuJour = 01/01/2007
The default is obviously set to " true. "
- rc: Section
This parameter displays the report page you want. By default, Reporting Services displays the first page of the report.
To view the second page, we write:
http://localhost/reportserver?%% 2fTest 2fMon + Report & rs: Command = Render & rc: Section = 2 & DateDuJour = 01/01/2007
This parameter is particularly useful if one wishes to develop its own toolbar.
- rc: Zoom
It is a given parameter can be operated with versions of Internet Explorer 5.0 or later.
Possible values for this parameter are: *
" page + width" to occupy the entire width of the browser,
* "Whole + page" to maximize space in the browser to view the report on a single page
* an integer corresponding to a percentage, the default is "100 .
- rc: LinkTarget
Useful if your report contains hyperlinks, this parameter can specify the window frame or the destination of links in your report.
The possible values include: *
"_blank "
* "_self "
* "_parent "
* " _top"
* Or any other valid target name .
- rc: FindString, rc: StartFind, rc: EndFind
The parameter rc: FindString can filter the records of the report. This parameter is often used in conjunction with the parameters rc: StartFind and rc: EndFind that can confine the search.
For example, to search for the string "Test " in the first 2 pages of the report, the URL will be:
http://localhost/reportserver?%% 2fTest 2fMon + Report & rc: FindString = Test & rc: StartFind = 1 & rc: EndFind = 2 & DateDuJour = 01/01/2007
- rc: Stylesheet
The last parameter I will elaborate in this post can define a style sheet to apply the report.
The CSS must be present in the repertoire of styles, default
C: \\ Program Files \\ Microsoft SQL Server \\ MSSQL \\ Reporting Services \\ ReportServer \\ Styles
To apply the stylesheet " mystyle.css ", the URL becomes :
http://localhost/reportserver?%% 2fTest 2fMon + Report & rs: Command = Render & rc: Stylesheet = myStyle & DateDuJour = 01/01/2007
Note as the report's call for the absence of extension.
I will conclude by the fact that most of the parameters presented here are valid as service packs Reporting Services 2000, and therefore this section does not apply only to users of Reporting Services 2005 .
soon for another article!
Subscribe to:
Posts (Atom)