Table with server-side processing extremely slow

Product: PowerShell Universal
Version: 5.6.1

Following @MS-Marox comment:

I recreated my table using the LoadData parameter.
In a simple test, everything worked fine, but when I used pre-production data (43 columns and about 120–150 rows), it became noticeably slower.

An even bigger slowdown occurred when I added paging and sorting — it was roughly 10× slower than a regular table. I didn’t even test it with the search parameter, since it would probably have exploded! :sweat_smile:

So, I switched back to the regular table. Yes, I lose the ability to use UDIconButtons instead of icons, but the responsiveness is almost instant.

The data for my table is an array already loaded in memory (not coming from SQL queries or API calls).
Shouldn’t it be the other way around?
Shouldn’t server-side processing actually be faster?

The advantage of server side processing is when you have 50000 rows, only the 20 you show in the page get transmitted.
The paging happens on the server.

Onrender slows tables down.
Make sure you only work on the data that is actually shown.

I use onrender to color text or display buttons or check boxes with tables that have over 20000 rows.
No issues.

I mirror what deroppi has put.

I use client side when I know the data set will be small and won’t grow, in which case it’s fast because it’s loading all the data in one go and then caching and presenting to the client.

I use server side when I know i’m into thousands of rows, in which case using client side will cause memory issues, or other problems. Using server-side with pagination in these cases isnt lightening fast because it has to make calls and render on the fly as you skip between pages, but its still perfectly usable imo. Though it ultimately depends on things like your infra, queries being used, indexing, etc etc

I understand idea well enough. But the reality shows otherwise.

Maybe because i have a lot columns (self generated).
Maybe for 20,000 rows it will be slow but regular approach will be even slower

But all i know that adding paging and sorting slowed it down to a point were it was not usable at all

I think it would be good to share your code if you can, I’ve got lots of colums and rows, lots of OnRender blocks and havent had any issues with my tables being unusable. Would be good to see how your code looks to see if there’s anything that can be attributed to the slowness

it basically @MS-Marox code with greater number of columns and rows:

New-UDApp -Title "43 Column Table" -Content {
    $columns = @(
        New-UDTableColumn -Property "Server" -Title "Server" -ShowSort
        (1..43 | ForEach-Object {
            $check_n = "Check$_"
            $OnRender = {
                $CheckProperty = $EventData.$Property
                if ($CheckProperty -eq "PASS") {
                    New-UDIconButton -Icon (New-UDIcon -Icon check -Color green -Size sm) -Size small -OnClick {
                        Show-UDToast "$($CheckProperty)" -Persistent -CloseOnClick
                    }
                }
                elseif ($CheckProperty -eq "FAIL") {
                    New-UDIconButton -Icon (New-UDIcon -Icon times -Color red -Size sm) -Size small
                }
                else {
                    New-UDIconButton -Icon (New-UDIcon -Icon ban -Color black -Size sm) -Size small
                }
            }
            New-UDTableColumn -Property "$check_n" -Title "Q$_" -OnRender $OnRender -Align center -ShowSort
        }
        )
    )

    $TableData = 1..150 | ForEach-Object {
        $InnerData = [PSCustomObject]@{
            Server = "Server_$_"
        }

        1..150 | ForEach-Object {
            $CheckKey = "Check$_"
            $RandomValue = Get-Random -Minimum 1 -Maximum 10
            $CheckValue = if ($RandomValue % 2 -eq 0) {
                "PASS"
            }
            elseif ($RandomValue % 3 -eq 0) {
                "FAIL"
            }
            else {
                "N/A"
            }
            Add-Member -InputObject $InnerData -NotePropertyName $CheckKey -NotePropertyValue $CheckValue
        }

        $InnerData
    }
    New-UDTable -Columns $columns -LoadRows {
        $TotalCount = $TableData.Count
        if (-not [string]::IsNullOrEmpty($EventData.OrderBy.Field)) {
            $Descending = $EventData.OrderDirection -ne 'asc'
            $TableData = $TableData | Sort-Object -Property ($EventData.orderBy.Field) -Descending:$Descending
        }
        $TableData = $TableData | Select-Object -First $EventData.PageSize -Skip ($EventData.Page * $EventData.PageSize)
        $TableData | Out-UDTableData -Page $EventData.Page -TotalCount $TotalCount -Properties $EventData.Properties
    } -Dense -ShowPagination -PageSize 10 -StickyHeader -RemoveCard -ShowSort
}

And i think I partially found the problem. My server (its was test server) is much weaker than PC on which im checking this app. On faster server probably this approach will produce acceptable results.

1 Like