I need some DataGrid performance help

Paul Dupuis paul at researchware.com
Tue May 5 16:38:47 EDT 2020

I have a datagid operation that should be fast that is taking a long 
time and I don't understand why.

I use a datagrid to display a table of data as part of an analysis. The 
columns are file names and the rows are selected phrases found in those 
files. The first column is the list of phrases (162 in this example). 
The remaining columns are all the file name (254 in this example). So 
each cell (2 to 254) represents a count of the number of times the 
phrase (in column 1 of the row) was found the the file that column 

I have the following code:

   set the dgColumnWidth[tRowColumnName]      of grp 
"rwMatrixObj_DataGrid" to 200
   set the dgColumnAlignment[tRowColumnName]  of grp 
"rwMatrixObj_DataGrid" to "left"
   set the dgColumnSortType[tRowColumnName]   of grp 
"rwMatrixObj_DataGrid" to "text"
   set the dgColumnIsEditable[tRowColumnName] of grp 
"rwMatrixObj_DataGrid" to false
   repeat with i=2 to the number of lines in tColumnNames
     put line i of tColumnNames into tColumnName
     set the dgColumnTooltip[tColumnName]    of grp 
"rwMatrixObj_DataGrid" to tColumnName
     set the dgColumnWidth[tColumnName]      of grp 
"rwMatrixObj_DataGrid" to 75
     set the dgColumnAlignment[tColumnName]  of grp 
"rwMatrixObj_DataGrid" to "right"
     set the dgColumnSortType[tColumnName]   of grp 
"rwMatrixObj_DataGrid" to "numeric"
     set the dgColumnSortDirection[tColumnName] of grp 
"rwMatrixObj_DataGrid" to "descending"
     set the dgColumnIsEditable[tColumnName] of grp 
"rwMatrixObj_DataGrid" to false
   end repeat

The first time this executes it takes just under 3 minutes for this size 
of data (254 columns). However, the second and each successive time in 
the same session it takes just under 30 minutes!

Any idea why it would take so long?

Thoughts on how to speed it up?

I realize that I could use: 'set the dgProp["column widths"] of grp <DG> 
to <returnDelimitedListOfWidths>' as a single set action vs a loop where 
I am using 'set the dgColumnWidth[tColumnName] of grp <DG> to 

However, there are only Datagid properties so set attributes for ALL 
columns for alignments, visibility, widths, and labels. Therefore, I 
have to use a loop anyway to set the tooltip, sorttype, sortdirection, 
end editability

The column names (in the variable tColumnNames) are file names. Some are 
long (longest is 113 characters) and some contain assorted punctuation. 
I wonder is the column NAMES should be somehting plain ASCII and short 
and the column LABELS contain the file names?

This is all in LiveCode 9.5.1 on Windows. Timing is approximately the 
same in a Standalone or the IDE.

Anyway, if anyone has a good idea of what is taking this 30 minutes, 
ideas would be very welcome!

More information about the use-livecode mailing list