gustavnavar / Grid.Blazor

Grid component with CRUD for Blazor (client-side and server-side) and ASP.NET Core MVC
GNU Lesser General Public License v2.1
692 stars 133 forks source link

Grid.Blazor suggested database optimizations #303

Open bytesfrombits opened 3 years ago

bytesfrombits commented 3 years ago

Is your feature request related to a problem? Please describe. Currently the query generated to fetch data to populate the Grid includes ALL fields defined in the column collection whether Visible or Hidden. In cases where Hidden columns are mapped to large table fields e.g fields defined as [nvarchar] or [varchar] in MS SQL containing large sets of textual data such as voluminous reports the memory overhead to page through the Grid is very HIGH as ALL such large table fields are included in each query to populate each page of the Grid yet the data from the large table fields is not used or displayed on the Grid.

Describe the solution you'd like

  1. Add a "GridExcluded" property to the Column object to mark a Column as totally excluded from a Grid e.g Columns.Add(o => o.Id, GridExcluded); Purpose:

    • To exclude all columns marked as "GridExcluded" from the query that is generated by Entity Framework to fetch and populate the Grid
    • To exclude all columns marked as "GridExcluded" from the Grid but include them in CRUD forms operations.
  2. As much as possible, utilise AsNoTracking() for database calls to populate the Grid with a goal to reducing the memory overhead of Entity Framework

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context This feature request would make Grid.Blazor more efficient with large datasets by reducing the memory overhead.

borisdj commented 3 years ago

If those are also hidden on Form one alternative solution would be to not use Entity directly with Grid but to have classes EntityModel with only needed properties and use AutoMapper for transformation. This structure has some other benefits as well. If on the other hand you would need them on the From then your proposed solution would be the way to go.

bytesfrombits commented 3 years ago

This is especially for specific cases where the Columns are to be excluded from Grid but included in forms for CRUD operations.