存档
top前言
记得很早以前就有人跟我说过,在使用count的时候要用count(1)而不要用count(*),因为使用count(*)的时候会对所有的列进行扫描,相比而言count(1)不用扫描所有列,所以count(1)要快一些。当时是对这一结论深信不疑,虽然不知道为什么。今天正好有时间研究研究看count(*)和count(1)到底有没有性能差异。
我的测试环境是SQL Server 2005 SP2开发版。
在进行测试之前先建立一些测试的数据,代码如下:
go
declare @n int
set @n = 1
while @n < 100000
begin
if @n%3 = 0
insert into test values (@n, null)
if @n%3 = 1
insert into test values (@n, str(@n))
if @n%3 = 2
insert into test values (@n, 'this is text')
set @n = @n+1
end
这里先说明一下,为了测试的目的,test表里面是故意没有加索引的。
阅读全文…
作者:马齿苋 | 链接:http://www.dbabeta.com/2008/sqlserver_howto_count.html
刚刚接触Oracle的时候就听过Tom Kyte的大名,他写的那本EXPERT ONE-ON-ONE ORACLE评价也是非常之高,不过因为我没有看过那本书,并不知道Tom的书为什么会那么的受欢迎。最近从dearbook上面看到有EXPERT ORACLE DATABASE ARCHITECTURE的样章,看了几章之后发现Tom的名声真不是盖的,书写的可以说是通俗易懂,而且还引用了很多实例进行解释,包括很多不同平台,不同数据库的对比,把概念阐述的非常清楚,澄清了很多以前不清晰的概念,于是赶紧的上网订了一本中文版,决定要好好的通读一遍,同时做好笔记,以备复习之用。
topPGA (Process Global Area)和UGA (User Global Area)
top基本概念说明
- PGA (Process Global Area)
- 进程或线程专用内存,其他进程或线程是不能访问的。
- UGA (User Global Area)
- UGA和特定的会话关联。 对用户来说UGA就是会话状态,对共享服务器在SGA中分配,对于专用服务器在PGA中分配。
topPGA的管理方法
top两种PGA管理
- 手动PGA管理
- 要设定每一个特定进程的允许用多少内存来进行排序,HASH等操作。
- 自动PGA管理
- 只需要告诉Oracle在系统范围里可以使用多少就行了。
topWORKAREA_SIZE_POLICY参数
系统初始化参数WORKAREA_SIZE_POLICY控制PGA管理方法, 此参数允许session级的修改,参数值如下:
- AUTO 自动管理,Oracle 9i/Release 1以上版本有效,Oracle 9i/Release 2以上版本默认为AUTO
- MANUAL 手动管理,Oracle9i Release 1默认值为MANUAL
作者:马齿苋 | 链接:http://www.dbabeta.com/2008/tomkyte_expert_oracle_reading_notes_ch04.html
本文概述与实验环境
概述:本文只讨论OS认证和口令文件认证方式的配置方法,如何配置以及使用OS认证和口令文件认证方式验证SYSDBA/SYSOPER权限。
实验环境:Oracle 10.1 + Windows 2003 和 Oracle 10.2 + RHEL 4
特殊权限与Oracle登陆认证管理
在开始学Oracle的时候有件事一直让我感觉很奇怪,就是为什么在数据没有起来的时候只要登录到安装Oracle的操作系统中直接用sqlplus / as sysdba就能登陆到数据库中然后对数据库进行启动停止之类的操作。后来看到关于Oracle口令文件相关资料的时候才豁然开朗:数据库认证信息并不一定存在数据库中的,这点和SQL Server很是不一样。
在Oracle中有两类特殊的权限SYSDBA和SYSOPER,当DBA需要对数据库进行维护管理操作的时候必须具有这两类特殊权限之中的一种。在数据库没有打开的时候,使用数据库内建的账号是无法登陆数据库的,但是拥有SYSDBA或是SYSOPER权限的用户是可以登陆的。认证用户是否拥有两类特殊权限的方法有两种:OS认证和口令文件认证。
阅读全文…
作者:马齿苋 | 链接:http://www.dbabeta.com/2008/oracle_os_pwfile_authentication.html
All about SQL Server 2005 database mail configuration
Reference:
http://technet.microsoft.com/zh-cn/library/ms177580.aspx
*************************************************************/
SP_CONFIGURE 'show advanced options', 1 ;
GO
RECONFIGURE ;
GO
SP_CONFIGURE 'Database Mail XPs', 1 ;
GO
RECONFIGURE ;
GO
/**************************************************
Config database mail
**************************************************/
-- Creates a new Database Mail account
EXECUTE msdb.dbo.sysmail_add_account_sp
@account_name = 'SQL Server Monitoring',
@description = 'SQL Server Monitoring',
@email_address = 'sql-monitoring@your-company.com',
@replyto_address = 'sql-monitoring@your-company.com',
@display_name = 'SQL Server Monitoring',
@mailserver_name = 'smtp.your-company.com',
@port = 25,
@enable_ssl = 0 ;
-- Create a Database Mail profile
EXECUTE msdb.dbo.sysmail_add_profile_sp
@profile_name = 'YourCompanyMailProfile',
@description = 'Profile used for Your Company SQL Servers.';
-- Add the account to the profile
EXECUTE msdb.dbo.sysmail_add_profileaccount_sp
@profile_name = 'YourCompanyMailProfile',
@account_name = 'SQL Server Monitoring',
@sequence_number =1 ;
-- Grant access to the profile to all users in the msdb database
EXECUTE msdb.dbo.sysmail_add_principalprofile_sp
@principal_name = 'public',
@profile_name = 'YourCompanyMailProfile',
@is_default = 1 ; -- later, you can update it through T-SQL: 'update sysmail_principalprofile set ...'
/**************************************************
Send mail and query all mail items
**************************************************/
-- After this configuration you can send mail by calling the system store procedure dbo.sp_send_dbmail
EXECUTE msdb.dbo.sp_send_dbmail
--@profile_name = 'YourCompanyMailProfile',
@recipients = 'MyEmail@your-company.com;',
@subject = 'Test Database Mail',
@body = 'Test e-mail body text';
-- Check send mail status
select sent_status,* from msdb.dbo.sysmail_allitems
/**************************************************
Remove all database mail settings
**************************************************/
-- Delete principal
EXECUTE msdb.dbo.sysmail_delete_principalprofile_sp
@principal_name = 'public';
-- Delete profile
EXECUTE msdb.dbo.sysmail_delete_profile_sp
@profile_name = 'YourCompanyMailProfile';
-- Delete account
EXECUTE msdb.dbo.sysmail_delete_account_sp
@account_name = 'SQL Server Monitoring' ;
GO
SP_CONFIGURE 'Database Mail XPs', 0 ;
GO
RECONFIGURE ;
GO
作者:马齿苋 | 链接:http://www.dbabeta.com/2008/sql2005_dbmail_configuration.html
近期评论