Skip to content

[RFC] Remove the use of Select-DefaultView #7415

Description

@wsmelton

I know this will be difficult to get acceptance for but here goes...

Summary of new feature

Replace the use of Select-DefaultView (internal function used for controlling the "default" output of commands) with proper (I'd say best practice) use of format and view ps1xml files.

Proposed technical details (if applicable)

In and of itself if you have not authored modules before the use of <module>.format.ps1xml and <module.types.ps1xml are a bit more cumbersome to use than Select-DefaultView. However, because we send the object in each command to another function (the internal one for the view) it adds unnecessary overhead that PowerShell will handle for us more efficiently.

An example of this can be seen with Get-DbaDatabase, with the internal function used on Codespaces environment with SQL Server on Linux it takes 278ms to return the object output:

image

Adjusting to use a the dbatools.format.ps1xml drops it to 247ms:

image

One additional thing we inherit with using a format file is that when multiple instances are queried the output will keep the table view output. We do not inherit this with our internal function.

image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions