Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.
Filter Performance
Hi, just looking for ideas here.
I have a large edit table, some 60k some 200k rows.
Population of the table is quick as it is indexed, and it just reads the index and feeds the ARRAY property.
I have a function where the user can select a filter, on up to 6 columns.
I do a loop/remove to process the list, so that in itself is quick.
Then I set the VISIBLE property to zero if the filter does not match, and at the end do a redraw.
This can take several minutes. I cant see anything I can do code wise to improve things.
Any thoughts if there are ways to make the table Visible row settings faster?
Code below
Thanks
Colin
SF_TABLE=Get_Property(FactorTable,"OLE.ARRAY")
SF_TABLE=SRP_ROTATE_ARRAY(SF_TABLE)
RowCount=DCOUNT(SF_TABLE,@FM)
SWAP @VM WITH "|" IN SF_TABLE
Position=1
TERM=0
TOTAL_ITEMS=RowCount
FOR ROW=1 TO RowCount until TERM
Remove Line From SF_TABLE At Position Setting flag
SWAP "|" WITH @FM IN Line
VISIBLE=1
IF SF_FILTER1 THEN
CELL1=Line<2>
IF CELL1#SF_FILTER1 THEN VISIBLE=0
END
IF SF_FILTER2 THEN
CELL2=Line<3>
IF CELL2#SF_FILTER2 THEN VISIBLE=0
END
IF SF_FILTER3 THEN
CELL3=Line<4>
IF CELL3#SF_FILTER3 THEN VISIBLE=0
END
IF SF_FILTER4 THEN
CELL4=Line<5>
IF CELL4#SF_FILTER4 THEN VISIBLE=0
END
IF SF_FILTER5 THEN
CELL5=Line<6>
IF CELL5#SF_FILTER5 THEN VISIBLE=0
END
IF SF_FILTER6 THEN
CELL6=Line<7>
IF CELL6#SF_FILTER6 THEN VISIBLE=0
END
IF VISIBLE=0 THEN
CALL Set_Property(FactorTable,"OLE.DataRow[":ROW:"]",@FM:VISIBLE)
END
ITEM_COUNT+=1
GOSUB UPDATE_STATUS
IF CANCEL THEN TERM=1
NEXT ROW
SF_TABLE=""
CALL END_DIALOG("STD_PROCESS")
CALL Set_Property(FactorTable,"OLE.Redraw",1)
I have a large edit table, some 60k some 200k rows.
Population of the table is quick as it is indexed, and it just reads the index and feeds the ARRAY property.
I have a function where the user can select a filter, on up to 6 columns.
I do a loop/remove to process the list, so that in itself is quick.
Then I set the VISIBLE property to zero if the filter does not match, and at the end do a redraw.
This can take several minutes. I cant see anything I can do code wise to improve things.
Any thoughts if there are ways to make the table Visible row settings faster?
Code below
Thanks
Colin
SF_TABLE=Get_Property(FactorTable,"OLE.ARRAY")
SF_TABLE=SRP_ROTATE_ARRAY(SF_TABLE)
RowCount=DCOUNT(SF_TABLE,@FM)
SWAP @VM WITH "|" IN SF_TABLE
Position=1
TERM=0
TOTAL_ITEMS=RowCount
FOR ROW=1 TO RowCount until TERM
Remove Line From SF_TABLE At Position Setting flag
SWAP "|" WITH @FM IN Line
VISIBLE=1
IF SF_FILTER1 THEN
CELL1=Line<2>
IF CELL1#SF_FILTER1 THEN VISIBLE=0
END
IF SF_FILTER2 THEN
CELL2=Line<3>
IF CELL2#SF_FILTER2 THEN VISIBLE=0
END
IF SF_FILTER3 THEN
CELL3=Line<4>
IF CELL3#SF_FILTER3 THEN VISIBLE=0
END
IF SF_FILTER4 THEN
CELL4=Line<5>
IF CELL4#SF_FILTER4 THEN VISIBLE=0
END
IF SF_FILTER5 THEN
CELL5=Line<6>
IF CELL5#SF_FILTER5 THEN VISIBLE=0
END
IF SF_FILTER6 THEN
CELL6=Line<7>
IF CELL6#SF_FILTER6 THEN VISIBLE=0
END
IF VISIBLE=0 THEN
CALL Set_Property(FactorTable,"OLE.DataRow[":ROW:"]",@FM:VISIBLE)
END
ITEM_COUNT+=1
GOSUB UPDATE_STATUS
IF CANCEL THEN TERM=1
NEXT ROW
SF_TABLE=""
CALL END_DIALOG("STD_PROCESS")
CALL Set_Property(FactorTable,"OLE.Redraw",1)
Comments
All rows are set visible, and redraw is set to zero at the start.
CALL Set_Property(FactorTable,"OLE.Redraw",0)
CALL Set_Property(FactorTable,"OLE.DataRow[All]",@FM:1)
The basic solution to get the best performance is to simply maintain two arrays (or lists). The original and the filtered. Just repopulate the SRP EditTable with the filtered array and then switch back to the original array when needed.
Sorry...I didn't realize Kevin was responding at the same time I was also answering your question otherwise I would stayed silent and avoided potential noise and confusion.
My issue is that the user can update the table, and if they then apply a filter the updates wont be there.
I will need to have a think if this is really an issue or not, maybe the user has to save before applying a filter.
I will advise any solutions for info.
Suppose I want to create the filtered list, any suggestions as to the best way?
The SRP_Array with JOIN is useful, but when there are multi-valued columns, it is not suitable.
I am thinking I just find each row, match, if visible then append to the new filtered table.
But... sort of hoping some SRP magic utility might prove useful.
This one however does not fit with that model. See example screen below. Filters in the dropdowns at the top.
In this case 220,000 rows. Reads the record and populates in about 1 or 2 seconds.
Oh well, I just have to write the code, no simple solutions in some cases.
Then it does a bunch of fast SRP array functions before populating.
So, not 200k reads.
But having said that 4m OI reads to build the structure works at about 20k per second.
Well hashed record keys and small items are very quick.