RSS

猜猜看,谁的效率会更高?

01 Dec

要获取存储组上所有邮箱账户的列表,请问下面3个命令哪个效率最高?

Get-Mailbox | where { (Get-MailboxDatabase $_.Database).StorageGroup.Name -eq ‘First Storage Group’ }

 

Get-MailboxDatabase | where { $_.StorageGroup.Name -eq ‘First Storage Group’ } | foreach { Get-Mailbox -Database $_.Name }

 

Get-Mailbox -Database ‘*\First Storage Group\*’

 

答案是最后一个,速度也快。原因?因为筛选器是内置的,且输入简单。那下面这个呢?

Get-Mailbox | where { $_.Database.parent.name -eq ‘First Storage Group’ }

靠你猜了~

Advertisements
 
3 Comments

Posted by on December 1, 2009 in Powershell

 

3 responses to “猜猜看,谁的效率会更高?

  1. December 2, 2009 at 09:06

    Get-Mailbox | where { $_.Database.parent.name -eq ‘First Storage Group’ }这个应该比前两个的效率高一些,因为减少了筛选次数,但是和最后一个比,就不知道了。

     
  2. December 2, 2009 at 10:40

    Get-Mailbox | where { $_.Database.parent.name -eq ‘First Storage Group’ }这个效率好像和最后一个一样 ?

     
  3. December 2, 2009 at 12:46

    第三个查询是找在第一个存储组上的所有邮箱,而前两种都是查询所有邮箱中在第一个存储组上的邮箱,整个查询的范围有很大的区别。另外,必须注意的是,在邮箱总数超过40000是,两种查询方式的查询时间会更大,具体的原因可参看powershell team blog。

     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: