Optimising performance for large data

Tags: #<Tag:0x00007efc646b41f0> #<Tag:0x00007efc646b5938>

Hi, I am using the non-commercial version of Handsontable with SvelteKit. Everything works super smooth when my data size is relatively small (up to 500 rows, 15 columns). But if the number of rows goes into thousands, the performance takes a hit.

I have tried all the optimisations suggested in the docs and more (reducing pre-rendering, removing auto resizing, removing sorting, cell editing, loading rows in view only mode) but can’t seem to make it work.

It’s clearly an issue in my codebase because this example with 50,000 rows and 35 columns seems to run just fine.

How can I optimise this configuration? bigDataView is a boolean flag that is true when the number of rows > 500.

  hot = new Handsontable(container, {
      data: dataRows,
      height: 'auto',
      colHeaders: true,
      dropdownMenu: bigDataView ? ['filter_by_condition', 'filter_operators', 'filter_by_value', 'filter_action_bar'] : true,
      hiddenColumns: {
        indicators: true,
      },
      contextMenu: bigDataView ? [] : ['cut', 'copy', '---------', 'undo', 'redo', '---------', 'mergeCells', 'row_above', 'row_below', 'col_left', 'col_right'],
      multiColumnSorting: bigDataView ? false : true,
      afterColumnSort() {
        if (hot && !bigDataView) {
          // after each sorting, take header row and change its index to 0
          hot.rowIndexMapper.moveIndexes(hot.toVisualRow(0), 0);
        }
      },
      cells(row) {
        if (row === 0 && !bigDataView) {
          return {
            type: 'text',
            className: 'htCenter',
            readOnly: $viewOnlyMode,
          };
        }
        return bigDataView ? { type: 'text', readOnly: true } : { readOnly: $viewOnlyMode };
      },
      fixedRowsTop: 1,
      filters: true,
      afterFilter() {
        if (hot) {
          const filtersPlugin = hot.getPlugin('filters');
          const filtersRowsMap = filtersPlugin?.filtersRowsMap;
          filtersRowsMap.setValueAtIndex(0, false);
        }
      },
      rowHeaders: true,
      colWidths: bigDataView ? getColumnWidth() : '100',
      viewportRowRenderingOffset: bigDataView ? 10 : 'auto',
      autoWrapCol: true,
      autoWrapRow: true,
      autoRowSize: bigDataView ? false : true,
      autoColumnSize: bigDataView ? false : true,
      allowInsertColumn: bigDataView ? false : true,
      allowInsertRow: bigDataView ? false : true,
      manualColumnMove: bigDataView ? false : true,
      manualRowMove: bigDataView ? false : true,
      manualColumnResize: bigDataView ? false : true,
      manualRowResize: bigDataView ? false : true,
      mergeCells: bigDataView ? false : true,
      persistentState: false,
      stretchH: bigDataView ? 'none' : 'all',
      search: bigDataView ? false : true,
      selectionMode: bigDataView ? 'single' : 'multiple',
      formulas: bigDataView ? undefined : { engine: hyperformulaInstance, sheetName: 'Sheet1' },
      licenseKey: "non-commercial-and-evaluation",
    });

I think I may have solved the issue by simply setting a fixed height and width in the options. Perhaps calculating those values is what slows HoT down for large data.

Edit: It seems you only need to fix the height. Everything else works just fine!

So if you have large data, make sure to set a fixed height in the options and there should be no performance hit.

Hi @heavy.rain6311

I’m not sure if I understood the status. Is there anything we could do for you at the Technical Support?

Hi @aleksandra_budnik

My issue is resolved so this thread can be closed.

My only question is whether declaring a fixed height for the hot instance is the recommended way for handling large data? If so, I would recommend that this be recorded in the documentation, perhaps under the Performance page.

You are right, @heavy.rain6311

Currently one would need to go to

and then read the whole guide - cause there is no particular paragraph for the height (core setting) and performance. I will leave a note about it in our internal ticketing system.