블로그 이미지
LifeisSimple

calendar

1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

Notice

2010. 7. 14. 14:08 Brain Trainning/DataBase

Top 10 SQL Server 2008 Features for ISV Applications

Author: Burzin Patel

Contributor: Kun Cheng

Reviewers: Sanjay Mishra, Denny Lee, Mike Ruthruff, Sharon Bjeletich, Mark Souza, Peter Carlin, Hermann Daeubler, Peter Scharlock, Wanda He

Microsoft® SQL Server® 2008 has hundreds of new and improved features, many of which are specifically designed for large scale independent software vendor (ISV) applications, which need to leverage the power of the underlying database while keeping their code database agnostic. This article presents details of the top 10 features that we believe are most applicable to such applications based on our work with strategic ISV partners. Along with the description of each feature, the main pain-points the feature helps resolve and some of the important limitations that need to be considered are also presented. The features are grouped into two categories: ones that do not require any application change (features 1-8) and those that require some application code change (features 9-10). The features are not prioritized in any particular order.

1  Data Compression

The disk I/O subsystem is the most common bottleneck for many database implementations. More disks are needed to reduce the read/write latencies; but this is expensive, especially on high-performing storage systems. At the same time, the need for storage space continues to increase due to rapid growth of the data, and so does the cost of managing databases (backup, restore, transfer, etc.).

Data compression introduced in SQL Server 2008 provides a resolution to address all these problems. Using this feature one can selectively compress any table, table partition, or index, resulting in a smaller on-disk footprint, smaller memory working-set size, and reduced I/O. Configurations that are bottlenecked on I/O may also see an increase in performance. In our lab test, enabling data compression for some ISV applications resulted in a 50-80% saving in disk space.

SQL Server supports two types of compressions: ROW compression, which compresses the individual columns of a table, and PAGE compression which compresses data pages using row, prefix, and dictionary compression. The compression results are highly dependent on the data types and data contained in the database; however, in general we’ve observed that using ROW compression results in lower overhead on the application throughput but saves less space. PAGE compression, on the other hand, has a higher impact on application throughput and processor utilization, but it results in much larger space savings. PAGE compression is a superset of ROW compression, implying that an object or partition of an object that is compressed using PAGE compression also has ROW compression applied to it. Compressed pages remain compressed in memory until rows/columns on the pages are accessed.

Both ROW and PAGE compression can be applied to a table or index in an online mode that is without any interruption to the application availability. However, partitions of a partitioned table cannot be compressed or uncompressed online. In our testing we found that using a hybrid approach where only the largest few tables were compressed resulted in the best overall performance, saving significant disk space while having a minimal negative impact on performance. We also found that compressing the smallest objects first minimized the need for additional disk space during the compression process.

To determine how compressing an object will affect its size you can use thesp_estimate_data_compression_savings system stored procedure. Database compression is only supported in SQL Server 2008 Enterprise and Developer editions. It is fully controlled at the database level and does not require any application change.

2  Backup Compression

The amount of data stored in databases has grown significantly in the last decade. resulting in larger database sizes. At the same time the demands for applications to be available 24x7 have forced the backup time-windows to shrink. In order to speed up the backup procedure, database backups are usually first streamed to fast disk-based storage and moved out to slower media later. Keeping such large disk-based backups online is expensive, and moving them around is time consuming.

With SQL Server 2008 backup compression, the backup file is compressed as it is written out, thereby requiring less storage, less disk I/O, and less time, and utilizing less network bandwidth for backups that are written out to a remote server. However, the additional processing results in higher processor utilization. In a lab test conducted with an ISV workload we observed a 40% reduction in the backup file size and a 43% reduction in the backup time.The compression is achieved by specifying the WITH COMPRESSION clause in the backup command (for more information, see SQL Server Books Online). To prevent having to modify all the existing backup scripts, there is also a global setting (using the Database Settings page of the Server Properties dialog box) to enable compression of all backups taken on that server instance by default; this eliminates the need to modify existing backup scripts. While the compression option on the backup command needs to be explicitly specified, the restore command automatically detects that a backup is compressed and decompresses it during the restore operation. Overall, backup compression is a very useful feature that does not require any change to the ISV application. For more information about tuning backup compression, see the technical note on Tuning the Performance of Backup Compression in SQL Server 2008.

Note: Creating compressed backups is only supported in SQL Server 2008 Enterprise and Developer editions; however, every SQL Server 2008 edition can restore a compressed backup.

3  Transparent Data Encryption

In most cases, organizations do well at securing their active data via the use of firewalls, physical security, and tightly controlled access policies. However, when the physical media such as the backup tape or disk on which the data resides is compromised, the above security measures are of no use, since a rogue user can simply restore the database and get full access to the data.

SQL Server 2008 offers a solution to this problem by way of Transparent Data Encryption (TDE). TDE performs real-time I/O encryption and decryption of the data and log files using a database encryption key (DEK). The DEK is a symmetric key secured by using a certificate stored in the master database of the server, or an asymmetric key protected by an Extensible Key Management (EKM) module.TDE is designed to protect data ‘at rest’; this means that the data stored in the .mdf, .ndf, and .ldf files cannot be viewed using a hex editor or some other such means. However, data that is not at rest, such as the results of a select statement in SQL Server Management Studio, continues to be visible to users who have rights to view the table. TDE should not be confused with column-level encryption, which is a separate feature that allows encryption of data even when it is not at rest.Encrypting a database is a one-time process that can be initiated via a Transact-SQL command and is executed as a background thread. You can monitor the encryption/decryption status using thesys.dm_database_encryption_keys dynamic management view (DMV).

In a lab test we conducted we were able to encrypt a 100-gigabyte (GB) database using the AES_128 encryption algorithm in about one hour. While the overheads of using TDE are largely dictated by the application workload, in some of the testing we conducted, the overhead was measured to be less than 5%.

One point worth mentioning is when backup compression is used to compress an encrypted database, the size of the compressed backup is larger than if the database were not encrypted; this is because encrypted data does not compress well.

TDE enables organizations to meet the demands of regulatory compliance and overall concern for data privacy.

TDE is only supported in the SQL Server 2008 Enterprise and Developer editions, and it can be enabled without changing an existing application.

4  Data Collector and Management Data Warehouse

Performance tuning and troubleshooting is a time-consuming task that usually requires deep SQL Server skills and an understanding of the database internals. Windows® System monitor (Perfmon), SQL Server Profiler, and dynamic management views helped with some of this, but they were often too intrusive or laborious to use, or the data was too difficult to interpret.

To provide actionable performance insights, SQL Server 2008 delivers a fully extensible performance data collection and warehouse tool also known as the Data Collector. The tool includes several out-of-the-box data collection agents, a centralized data repository for storing performance data called management data warehouse (MDW), and several precanned reports to present the captured data. The Data Collector is a scalable tool that can collect and assimilate data from multiple sources such as dynamic management views, Perfmon, Transact-SQL queries, etc., using a fully customizable data collection and assimilation frequency.  The Data Collector can be extended to collect data for any measurable attribute of an application. For example, in our lab test we wrote a custom Data Collector agent job (40 lines of code) to measure the processing throughput of the workload.

The diagram below depicts a typical Data Collector report.

Data Collector

The Performance data collection and warehouse feature is supported in all editions of SQL Server 2008.

5  Lock Escalation

Lock escalation has often caused blocking and sometimes even deadlocking problems for many ISV applications. Previous versions of SQL Server permitted controlling lock escalation (trace flags 1211 and 1224), but this was only possible at an instance-level granularity. While this helped some applications work around the problem, it caused severe issues for others. Another problem with the SQL Server 2005 lock escalation algorithm was that locks on partitioned tables were directly escalated to the table level, rather than the partition level.

SQL Server 2008 offers a solution for both these issues. A new option has been introduced to control lock escalation at a table level. If an ALTER TABLE command option is used, locks can be specified to not escalate, or to escalate to the partition level for partitioned tables. Both these enhancements help improve the scalability and performance without having negative side-effects on other objects in the instance. Lock escalation is specified at the database-object level and does not require any application change. It is supported in all editions of SQL Server 2008.

6   Plan Freezing

SQL Server 2005 enabled greater query performance stability and predictability by providing a new feature called plan guides to enable specifying hints for queries that could not be modified directly in the application (for more information, see the white paper Forcing Query Plans). While a very powerful feature, plan guides were often cumbersome to use due to the sensitivity of the plan guides to the formatting, and only supported SELECT DML operations when used in conjunction the USE PLAN query hint.

SQL Server 2008 builds on the plan guides mechanism in two ways: it expands the support for plan guides to cover all DML statements (INSERT, UPDATE, DELETE, MERGE), and introduces a new feature,Plan Freezing, that can be used to directly create a plan guide (freeze) for any query plan that exists in the SQL Server plan cache, for example:

sp_create_plan_guide_from_handle

@name =  N'MyQueryPlan',

@plan_handle = @plan_handle,

@statement_start_offset = @offset;

A plan guide created by either means have a database scope and are stored in the sys.plan_guidestable. Plan guides are only used to influence the query plan selection process of the optimizer and do not eliminate the need for the query to be compiled. A new function sys.fn_validate_plan_guidehas also been introduced to validate existing SQL Server 2005 plan guides and ensure their compatibility with SQL Server 2008. Plan freezing is available in the SQL Server 2008 Standard, Enterprise, and Developer editions.

7  Optimize for Ad hoc Workloads Option

Applications that execute many single use ad hoc batches (e.g., nonparameterized workloads) can cause the plan cache to grow excessively large and result in reduced efficiency. SQL Server 2005 offered the Parameterization Forced database option to address such scenarios, but that sometimes resulted in adverse side-effects on workloads that had a large skew in the data and had queries that were very sensitive to the underlying data.

SQL Server 2008 introduces a new option, optimize for ad hoc workloads, which is used to improve the efficiency of the plan cache. When this option is set to 1, the SQL Server engine stores a small stub for the compiled ad hoc plan in the plan cache instead of the entire compiled plan, when a batch is compiled for the first time. The compiled plan stub is used to identify that the ad hoc batch has been compiled before but has only stored a compiled plan stub, so that when this batch is invoked again the database engine compiles the batch, removes the compiled plan stub from the plan cache, and replaces it with the full compiled plan.

This mechanism helps to relieve memory pressure by not allowing the plan cache to become filled with large compiled plans that are not reused. Unlike the Forced Parameterization option, optimizing for ad hoc workloads does not parameterize the query plan and therefore does not result in saving any processor cycles by way of eliminating compilations. This option does not require any application change and is available in all editions of SQL Server 2008.

8  Resource Governor

Maintaining a consistent level of service by preventing runaway queries and guaranteeing resources for mission-critical workloads has been a challenge for SQL Server. In the past there was no way of guaranteeing a certain amount of resources to a set of queries and prioritizing the access; all queries had equal access to all the available resources.

SQL Server 2008 introduces a new feature, Resource Governor, which helps address this issue by enabling users to differentiate workloads and allocate resources as they are requested. The Resource Governor limits can easily be reconfigured in real time with minimal impact on the workloads that are executing. The allocation of the workload to a resource pool is configurable at the connection level, and the process is completely transparent to the application.

The diagram below depicts the resource allocation process. In this scenario three workload pools (Admin workload, OLTP workload, and Report workload) are configured, and the OLTP workload pool is assigned a high priority. In parallel two resource pools (Admin pool and Application pool) are configured with specific memory and processor (CPU) limits as shown. As final steps, the Admin workload is assigned to the Admin pool, and the OLTP and Report workloads are assigned to the Application pool.

Resource Governor

Below are some other points you need to consider when using resource governor:

·         Since Resource Governor relies on login credentials, host name, or application name as a resource pool identifier, most ISV applications that use a single login to connect multiple application users to SQL Server will not be able to use Resource Governor without reworking the application. This rework would require the application to utilize one of the resource identifiers from within the application to help differentiate the workload.

·         Database-level object grouping, in which the resource governing is done based on the database objects being referenced, is not supported.

·         Resource Governor only allows resource management within a single SQL Server instance. For multiple instances. Windows System Resource Manager should be considered.

·         Only processor and memory resources can be configured. I/O resource cannot be controlled.

·         Dynamically switching workloads between resource pools once a connection is made is not possible.

·         Resource Governor is only supported in SQL Server 2008 Enterprise and Developer editions and can only be used for the SQL Server database engine; SQL Server Analysis Services (SSAS), SQL Server Integration Services (SSIS), and SQL Server Reporting Services (SSRS) cannot be controlled.

9  Table-Valued Parameters

Often one of the biggest problems ISVs encountered while developing applications on earlier versions of SQL Server was the lack of an easy way to execute a set of UPDATE, DELETE, INSERT operations from a client as a single batch on the server. Executing the set of statements as singleton operations resulted in a round trip from the client to the server for each operation and could result in as much as a 3x slowdown in performance.

SQL Server 2008 introduces the table-valued parameter (TVP) feature, which helps resolve this problem. Using the new TVP data type, a client application can pass a potentially unlimited sized array of data directly from the client to the server in a single-batch operation. TVPs are first-class data types and are fully supported by the SQL Server tools and SQL Server 2008 client libraries (SNAC 10 or later). TVPs are read-only, implying that they can only be used to pass array-type data into SQL Server; they cannot be used to return array-type data.

The graph below plots the performance of executing a batch of insert statements using a parameter array (sequence of singleton operations) vs. executing the same batch using a TVP. For batches of 10 statements or less, parameter arrays perform better than TVPs. This is due to the one-time overhead associated with initiating the TVP, which outweighs the benefits of transferring and executing the inserts as a single batch on the server.

However, for batches larger than 10 statements, TVPs outperform parameter arrays, because the entire batch is transferred to the server and executed as a single operation. As can be seen in the graph for a batch of 250 inserts the amount of time taken to execute the batch is 2.5 times more when the operations are performed using a parameter array versus a TVP. The performance benefits scale almost linearly and when the size of the batch increases to 2,000 insert statements, executing the batch using a parameter array takes more than four times longer than using a TVP.

TVP Graph

TVPs can also be used to perform other functions such as passing a large batch of parameters to a stored procedure. TVPs are supported in all editions of SQL Server 2008 and require the application to be modified.

10  Filestream

In recent years there has been an increase in the amount of unstructured data (e-mail messages, documents, images, videos, etc.) created. This unstructured data is often stored outside the database, separate from its structured metadata. This separation can cause challenges and complexities in keeping the data consistent, managing the data, and performing backup/restores.

The new Filestream data type in SQL Server 2008 allows large unstructured data to be stored as files on the file system. Transact-SQL statements can be used to read, insert, update and manage the Filestream data, while Win32® file system interfaces can be used to provide streaming access to the data. Using the NTFS streaming APIs allows efficient performance of common file operations while providing all of the rich database services, including security and backup. In our lab tests we observed the biggest performance advantage of streaming access when the size of binary large objects (BLOBs) was greater than 256 kilobytes (KB). The Filestream feature is initially targeted to objects that do not need to be updated in place, as that is not yet supported.

Filestream is not automatically enabled when you install or upgrade SQL Server 2008. You need to enable it by using SQL Server Configuration Manager and SQL Server Management Studio. Filestream requires a special dedicated filegroup to be created to store the Filestream (varbinary(max)) data that has been qualified with the Filestream attribute. This filegroup points to an NTFS directory on a file system and is created similar to all the other filegroups. The Filestream feature is supported in all editions of SQL Server 2008, and it requires the application to be modified to leverage the Win32 APIs (if required) and to migrate the existing varbinary data.

SQL Server 2008 is a significant release that delivers many new features and key improvements, many of which have been designed specifically for ISV workloads and require zero or minimal application change.

This article presented an overview of only the top-10 features that are most applicable to ISV applications and help resolve key ISV problems that couldn’t easily be addressed in the past. For more information, including a full list of features and detailed descriptions, see SQL Server Books Online and the SQL Server web site.

 

Published Nov 24 2008, 01:24 PM by Burzin

Filed under: Maintenance, Query, Performance, OLTP, Table Valued Parameters, Transparent Data Encryption, Backup Compression, Filestream, Resource Governor, Encryption, Data Compression, MDW, Data Collector, TDE, Compression, Statistics


출처 : http://sqlcat.com/top10lists/archive/2008/11/24/top-10-sql-server-2008-features-for-isv-applications-burzin.aspx

'Brain Trainning > DataBase' 카테고리의 다른 글

Categories of DMOs  (0) 2010.07.16
SQL Server 2005 DBCC Command Quick Reference  (0) 2010.07.16
SQL Server 2008 T-SQL Enhancements  (0) 2010.07.14
SQL Patch 정보  (0) 2010.06.18
MSSql 2005 SP 적용  (0) 2010.06.18
posted by LifeisSimple
2010. 7. 14. 14:03 Brain Trainning/DataBase

'Brain Trainning > DataBase' 카테고리의 다른 글

SQL Server 2005 DBCC Command Quick Reference  (0) 2010.07.16
Top 10 SQL Server 2008 Features for ISV Applications  (1) 2010.07.14
SQL Patch 정보  (0) 2010.06.18
MSSql 2005 SP 적용  (0) 2010.06.18
DBA 일간 체크리스트  (0) 2010.06.03
posted by LifeisSimple
2010. 6. 18. 11:14 Brain Trainning/DataBase
요기를 참고해 주세요.

http://www.sqlsecurity.com/FAQs/SQLServerVersionDatabase/tabid/63/Default.aspx


된장 패치가 무슨 애들 장난이냐...
워드치는거냐
posted by LifeisSimple
2010. 6. 18. 00:05 Brain Trainning/DataBase
SQL Server SP 적용할때 언제 서비스가 중단될까요? 
지금까지 크게 신경 안썻던 부분인데 음.. 요즘 이리 저리 많이 신경쓰게 되고 많은 관심을 가지게 되네요... 

대략 서비스 중단 시점은... 쭈욱~ 이 아니라 다음과 같습니다. 

1. Database Service 업데이트 하는 시점 : 대략 10분 정도
2. SQL Server Native Client 업데이트 시점 : 대략 5분 정도

이정도 서비스 중단이 되더군요... 

그리고, 마지막으로 Reboot 하는 시점입니다. ㅎ

그리 오래 되는건 아니더군요... 참고해야 할 것 같습니다. 



'Brain Trainning > DataBase' 카테고리의 다른 글

SQL Server 2008 T-SQL Enhancements  (0) 2010.07.14
SQL Patch 정보  (0) 2010.06.18
DBA 일간 체크리스트  (0) 2010.06.03
Optimising Server-Side Paging - Part II (펌)  (0) 2010.05.24
Replication Across Non-Trusted Domains (펌)  (0) 2010.05.17
posted by LifeisSimple
2010. 6. 7. 15:21 Brain Trainning
Shift-Space로 한/영 전환을 하는게 편해서 이리저리 찾아서 받은 데이터입니다. 

더블클릭해서 적용해 주면 됩니다. 

어디선가 펌질한 건데 어딘지 잘 기억이 없네요... 

'Brain Trainning' 카테고리의 다른 글

[MAC] Keynote 사용설명서....  (0) 2012.02.23
MS 워드를 활용한 블로그 글올리기  (1) 2011.01.09
가상화 관련 링크  (0) 2010.11.18
MS 2009 PDC 자료  (0) 2010.07.15
각 나라별 사용 IP대역  (0) 2010.05.06
posted by LifeisSimple
2010. 6. 3. 12:02 Brain Trainning/DataBase
1. Make sure each of your production databases are available and accessible
to their users.
2. Check all processes - such as clustering, replication, service
broker, log shipping, database mirroring - to verify that they are running correctly.
3. Check OS, SQL Server, Security, and other logs for unusual events.
4. Verify that all scheduled jobs have run successfully, including checking for long running or "hung" jobs.
5. Confirm that backups have been made and successfully saved to a secure
location.
6. Monitor disk space to ensure your SQL Servers won't run out of disk space. For best performance, all disks should have 15% or more of free space.
7. Throughout the day, periodically monitor SQL Server performance using Performance Monitor, Profiler/SQL Trace, or other performance monitoring
tools.
8. Regularly monitor and identify blocking issues.
9. Keep a log of any changes you make to servers, including documentation
of any performance issues you identify and correct.
10. Regularly restore backups to a test server in order to verify that you can restore them. You don't need to restore all backups every day, but do so often to ensure that you are confident you have good backups.
11. Take some time to learn something new as a DBA to further your professional development.
12. Automate as many of these day-to-day tasks as possible.

This list of best practices is not intended to be complete, but to get you started on your way to becoming an exceptional DBA. Always keep in mind that these suggestions are generic, and may or may not apply to your specific situation.
Brad McGehee's
Day-to-Day DBA Best Practices

출처: RedGate

'Brain Trainning > DataBase' 카테고리의 다른 글

SQL Patch 정보  (0) 2010.06.18
MSSql 2005 SP 적용  (0) 2010.06.18
Optimising Server-Side Paging - Part II (펌)  (0) 2010.05.24
Replication Across Non-Trusted Domains (펌)  (0) 2010.05.17
Optimising Server-Side Paging (펌)  (0) 2010.05.04
posted by LifeisSimple
2010. 5. 24. 17:41 Brain Trainning/DataBase

Optimising Server-Side Paging - Part II

Introduction

In part I of this series, we looked at an optimisation that is useful when paging through a wide data set.

This part examines four methods commonly employed to return the total number of rows available, at the same time as returning the single page of rows needed for display.

Each tested method works correctly; the focus of this article is to identify the performance characteristics of each method, and explore the reasons for those differences.

Sample Data

This part uses a single table containing one million rows of meteorological data collected at an imaginary weather station.

The code to create a test database, load the sample data, and run the full test suite is included in the Resources section at the end of this article.

Tested Methods

The Count Over Method

The first tested method uses the OVER clause extension to the COUNT aggregate. The syntax needed to count all the rows in the query (not just those on the requested page) is very simple:

The Double Row Number Method

The second method uses two ROW_NUMBER functions to determine the total number of rows, using a technique described in this SQL Server Central article by Robert Cary.

The basic idea is to number the rows in the whole set twice: once in ascending order, and once in descending order. It turns out that the sum of these two numbers (in every row) equals the count of rows in the whole set, plus one. This neat trick can be accomplished with the following code:

The Sub-query Method

The third idea is to use a simple COUNT sub-query, which duplicates the conditions in the main paging query.

The Indexed View Method

The last of the four methods uses an indexed view that contains an aggregated record count per day. The total record count is calculated by summing daily record count subtotals.

Using the view to compute the record count:

Test Results

Each test uses the same basic paging mechanism described in part I of this series, with a small section of code added to count the overall total number of rows. The test query includes all one million test rows in the paged data set.

The tests were run on a single-core machine running SQL Server 2008 Developer Edition, version 10.0.2766. The code has also been tested on SQL Server Developer Edition, version 9.0.4285.

All system caches were cleared before each test run, and the SQL Server read-ahead mechanism was disabled.

Each test use the same million-row data set, using 25 rows per page. Three tests were run using each method, to return data from the first, last, and middle pages of the set.

The data concerning physical reads, logical reads, CPU time, and elapsed time were obtained from the sys.dm_exec_query_stats dynamic management view, and validated against Profiler output. Buffer pool usage was determined from sys.dm_os_buffer_descriptors. Memory grants were obtained from actual execution plans generated on separate runs.

For each performance category in the summary tables below, the best results are shown in green, and the worst in orange.

First page

Middle page

Last page

Analysis

Count Over

This method performs a very large number of logical reads, and requires a memory grant of almost 46MB for sorting. A look at the relevant part of the execution plan for this method reveals the causes:

COUNT(*) OVER() is implemented using a special kind of sub-expression spool, known as a Segment Spool. The idea is to break the input up into groups (the Segment iterator), write each group to a worktable (the Spool), count the rows using a Stream Aggregate, and then join the count back onto the original rows as a new column.

The high number of logical reads incurred by this method is caused by the joins and by replaying the spooled rows twice: once to compute the row count, and then again to join the count back onto each row. The logical writes are caused by writing the rows to the spool.

The large memory grant is requested by the highlighted Sort operator. In current versions of SQL Server, the optimiser introduces this sort to guarantee the order of rows presented to a TOP operator later in the plan (not shown for space reasons). The required sort order is the same as that provided by the initial Index Seek - perhaps future optimisers will be able to take advantage of that and avoid this expensive sort altogether.

The million-row sort also contributes to the high CPU utilisation of this method.

Double Row Number

This method is the slowest overall, with high CPU usage, a large memory grant, and the largest number of physical reads.

Although the initial Index Seek provides rows in the correct order for the first row numbering operation, an explicit sort is required for the second.

Another explicit sort (the Top N Sort) is required to select the keys for the single page requested. Ironically, this sort puts the rows back in the original order provided by the Index Seek.

The two sorts both have to process one million rows, though the memory granted for the first sort can be reused by the second.

Sub-Query

The sub-query method produces a nice simple plan, and performs very well:

The top row of the plan performs the count sub-query. Since the query is guaranteed to produce a single row, it can be joined directly to the Index Seek that provides the keys for the page of data to return.

The lower Index Seek provides page keys in sorted order, so for page one, it only needs to return the first 25 keys. The biggest cost in this plan is counting the million rows in the Stream Aggregate.

Indexed View

This is the best-performing solution overall:

This plan is very similar to that produced by the sub-query method, but instead of counting one million rows, the top row of the plan is able to sum the partial counts stored in the indexed view - so only 695 rows flow through the Stream Aggregate (rather than one million).

This dramatic reduction in row count pays dividends across all the performance categories. In particular, it reduces the number of data and index pages which must be read in to the data cache from disk.

Conclusion

The count over and double row number methods are not really suited to large data sets, due to the cost of the sorts and spools.

The sub-query method is much more efficient, and is limited only by the costs associated with counting the qualifying rows.

The indexed view method improves further on the sub-query method, by maintaining useful partial aggregates. This is similar to the idea of keeping counts in a separate table using a system of triggers.

Resources:

Optimising Server-Side Paging Part II.sql

By Paul White, 2010/05/24

Total article views: 948 | Views in the last 30 days: 948 

출처 : http://www.sqlservercentral.com/articles/paging/70120/

'Brain Trainning > DataBase' 카테고리의 다른 글

MSSql 2005 SP 적용  (0) 2010.06.18
DBA 일간 체크리스트  (0) 2010.06.03
Replication Across Non-Trusted Domains (펌)  (0) 2010.05.17
Optimising Server-Side Paging (펌)  (0) 2010.05.04
Server Side Paging with SQL Server 2005 (펌)  (0) 2010.05.04
posted by LifeisSimple
2010. 5. 17. 19:07 Brain Trainning/DataBase

Replication Across Non-Trusted Domains or Using the Internet

Replication over the internet or across non-trusted domains is usually performed using a virtual private network (VPN), and consequently the configuration is much the same as that used on a LAN. This article outlines what to do if such a VPN is not available. While it's true that in almost all cases you wouldn't consider making SQL Server available directly to the internet, loosely -coupled networks in a hosted environment are commonplace. These systems ensure integrity by the use of firewall rules, resulting in DMZ/ECZ layers and causing serious issues for the would-be replicator. This is very much a 'how-to' guide, as the intricacies of network connectivity setup would otherwise make the article too long.
In replicating over non-trusted networks, the main additional considerations over and above a normal setup are:

(a) when configuring the subscriber, the publisher will not initially be visible in enterprise manager, and cannot be added in the usual way.

(b) after the snapshot has been created, it is normally accessed by the merge/distribution agent using the repldata share, which will be unavailable over the internet.

(c) the replication agents normally run under the context of a windows user account and are impersonated at the distributor/publisher, however an AD lookup at the publisher when accessing the snapshot files will not be able to find the windows user.

What follows is a list of the configuration changes necessary to solve these issues.

(i) Network Configuration - Ports etc

SQL communication needs to be enabled on the port defined at the publisher. For a default instance this is typically port 1433 while FTP uses port 21 by default. So, rules allowing the subscriber's IP address access on these ports through the firewall need to be set up, implying that the subscriber must not get a leased DHCP IP address, but have a fixed address of its own. In SQL Server 2005 merge replication is possible over port 443 (SSL/HTTP) - more on that in another article - but for our case, the security is provided by the use of logins and passwords, firewall rules, and encryption if necessary.

(ii) Publication Configuration

The repldata share on the publisher that is normally used to hold the snapshot initialization files will be unavailable - discounting the use of a guest windows login at the publisher which is simply too insecure a method to consider - so an alternative initialization method is needed. The main choices are automatic FTP and alternative snapshot locations at the subscriber. For the latter, when a pull subscription is created, it can be pointed at a local directory for the snapshot files. I often use this method as my snapshot files are so large (>40GB) that I save a lot of time doing the whole thing manually. Basically, this involves the creation of the snapshot, compressing the directory using WinZip 9.0, manually FTPing to the subscriber then unziping locally. After that I use the alternative snapshot location (@alt_snapshot_folder) on the subscriber to initialize. This method is used because although compression using CAB files is available within the publication wizard, it is limited to a maximum size of 2GB.


This article however will concentrate on the inbuilt, automatic method of FTP which is configured at the publisher on the snapshot location tab. If all the subscribers need to be set up in the same way (non-trusted domains etc) then on this tab only the second checkbox is selected at the top. The snapshot folder lies under the FTPROOT directory and 'Subscribers can access this folder using FTP' obviously needs to be selected. If you do choose to compress, the files will be uncompressed using the Temp folder of the subscriber, so you must check that you have enough space. The client path is the path from the FTP root directory, so in this case is \TRSnapshot\ftp. The login can be left as the default for anonymous access (not recommended) or a valid windows login at the publisher is selected that has read access to the FTPROOT directory – PaulI in this case.

(iii) alias configuration at subscriber

In order for the subscriber to 'see' the publisher, an alias must be created in the client network utility before registering the publisher in Enterprise Manager. This is mandatory as the use of an IP address in Enterprise Manager will later result in various errors. Be sure to:
(a) use TCP/IP and not named pipes, otherwise you'll get a "SQL server does not exist or access is denied." error.
(b) create an alias that has exactly the same name as the publisher/distributor.


(iv) hosts file configuration at the subscriber

The FTP request at the subscriber needs to be able to associate the publisher/distributor's NETBIOS name with its IP address. As we have a non-trusted environment, this entry won't exist on the DNS on the subscribers’s LAN, so we manually add it to the HOSTS file on the subscriber, located in C:\WINNT\system32\drivers\etc. After the hashed out section, the file should look like the text below, where DOHXXX-SQL is the Publisher/Distributor's netbios name.

127.0.0.1 localhost
62.6.139.105 DOHXXX-SQL


If this is omitted, the error message will be the FTP initialization error : “Message: The process could not connect to FTP site 'DOHCOL-SQL' using port 21”.

(v) Create a PULL Subscription

When using the Pull subscription wizard, the ‘Choose Publication’ form allows browsing of the publisher’s publications. The publisher can be added to EM at this stage or already be configured. If everything has been correctly set up using the previous steps, the publications list should be visible. The synchronization agent login should be set to use a SQL login (pass-through is possible but let’s leave that for now) already added to the PAL. If the subscriber is registered at the publisher, this can be a named subscription, otherwise it’ll be anonymous. The only other thing to set up is to select the option to ‘Download using FTP’ on the Snapshot Delivery form.

posted by LifeisSimple
2010. 5. 12. 19:27 Brain Trainning/PRG Language

'Brain Trainning > PRG Language' 카테고리의 다른 글

[MSSQL] JDBC 연결  (0) 2011.02.25
[MongoDB] Comparison of data serialization formats  (0) 2011.01.18
MSSQL + PHP 연동  (0) 2010.12.21
Connection String 세팅  (0) 2010.12.03
Programming Windows Phone 7, by Charles Petzold  (0) 2010.10.29
posted by LifeisSimple
2010. 5. 6. 16:13 Brain Trainning

http://www.maxmind.com/app/geolitecountry


위의 사이트에서~ 다운받아서

'Brain Trainning' 카테고리의 다른 글

[MAC] Keynote 사용설명서....  (0) 2012.02.23
MS 워드를 활용한 블로그 글올리기  (1) 2011.01.09
가상화 관련 링크  (0) 2010.11.18
MS 2009 PDC 자료  (0) 2010.07.15
Shift-Space 로 한영전환 Reg  (0) 2010.06.07
posted by LifeisSimple