Hello Wagner,
I have the problem that a REST call takes 43 seconds.
I try to explain it.
I have 2 tables. It is a closure table structure that is supposed to represent a tree.
"Warengruppe" has 25 entries and "WarengruppeCT" has 44 entries.
The tree has 6 entries on level 0.
On level 1 are 2 to 7 entries. No more levels.
The two relationships are lazy.
The Aurelius DB call only takes a few milliseconds.
The entire call takes 43 seconds.
( I have tested with Postman)
2024-07-04 10:43:30.935 × 20420 × sngWare × Enter: WarengruppeList_v1 {"Function":"","Version":"801","Data":{}}
2024-07-04 10:43:30.951 × 20420 × sngWare × Leave: WarengruppeList_v1 ResultCount=6
2024-07-04 10:44:14.334 × 20420 × sngWare × POST /sopha/w/func/WarengruppeList 200 - 43410,21 ms
The service interface:
IWareFunc = interface(IInvokable)
['{6DEEED43-7611-4E90-A57C-A4FBE7C26CE4}']
function WarengruppeList ( const Param: TJSONObject) : TList<TWarengruppe>; // Para: WarengruppeID oder Filter
The service implementation (part 1, only the call to an other unit (###)):
function TWareFunc.WarengruppeList( const Param: TJSONObject): TList<TWarengruppe>;
var
LObjManager : TObjectManager;
LsngPara : TsngParameter;
LJson : TJSONObject;
begin
Result := nil;
LsngPara := nil;
if TsngParameter.CheckCall( Param, local_location_prefix, cIWare_WarengruppeList,
LJson, LsngPara,
vcWare_OldestVersion, vcWare_CurrentVersion) then begin
LObjManager := TXDataOperationContext.Current.GetManager;
if (LsngPara.VersionCode > 0) and (LsngPara.VersionCode <= vcWare_v1) then
Result := (###) WarengruppeList( LObjManager, LsngPara); (###)
end;
if LJson <> nil then
LJson.Free;
if LsngPara <> nil then
LsngPara.Free;
end;
The service implementation (part 2)):
class function TWareFuncHelper.WarengruppeList( const ObjManager: TObjectManager; const AsngParam: TsngParameter): TList<TWarengruppe>;
var
LWarengruppeID: TGUID;
begin
local_func_name := cIWare_WarengruppeList+'_v1';
DoLog( loaTraceAll, 'Enter: '+local_func_name+' '+AsngParam.toJSONString);
try
LWarengruppeID := DirtyStringToGuid( AsngParam.JSONData.Values[ DicWare.Warengruppe.WarengruppeID.PropName].AsType<String>);
except
LWarengruppeID := TGUID.Empty;
end;
if LWarengruppeID.IsEmpty then
Result := ObjManager.Find<TWarengruppe>
.Where( Linq.Sql('wg_id in (select wgct_child from t_w_warengruppect '+
'group by wgct_child having count(wgct_child)=1)'))
.List
else
Result := ObjManager.Find<TWarengruppe>
.Where( Linq.Sql('wg_id in (select wgct_child from t_w_warengruppect '+
'where wgct_parent='''+GetGuidString( LWarengruppeID, guid36)+''' and wgct_deep=1)'))
.List;
DoLog( loaTraceAll, 'Leave: '+local_func_name+' ResultCount='+Result.Count.toString);
end;
Parameter ID is empty.
I get this result:
{
"value": [
{
"$id": 1,
"WarengruppeID": "3201466D-BF3B-484D-BAB1-18221DFB190E",
"Bezeichnung": "Edelmetall",
"Kuerzel": "",
"Nummer": "0",
"WareList@xdata.proxy": "Warengruppe(3201466D-BF3B-484D-BAB1-18221DFB190E)/WareList",
"Ware@xdata.ref": "Ware(1C50385C-BF5F-4BC7-96C5-B38A44FFF836)"
},
{
"$id": 2,
"WarengruppeID": "FCE7CF27-D911-4F48-9F80-1A0DFFCEE2C9",
"Bezeichnung": "Uhren",
"Kuerzel": "",
"Nummer": "0",
"WareList@xdata.proxy": "Warengruppe(FCE7CF27-D911-4F48-9F80-1A0DFFCEE2C9)/WareList",
"Ware": null
},
{
"$id": 3,
"WarengruppeID": "CCF593A6-D497-4D58-948E-648327D0FFDE",
"Bezeichnung": "Technik",
"Kuerzel": "",
"Nummer": "0",
"WareList@xdata.proxy": "Warengruppe(CCF593A6-D497-4D58-948E-648327D0FFDE)/WareList",
"Ware": null
},
{
"$id": 4,
"WarengruppeID": "09FF8220-85FA-40B0-9391-683AA35DB91B",
"Bezeichnung": "Fahrzeuge",
"Kuerzel": "",
"Nummer": "0",
"WareList@xdata.proxy": "Warengruppe(09FF8220-85FA-40B0-9391-683AA35DB91B)/WareList",
"Ware": null
},
{
"$id": 5,
"WarengruppeID": "865C6A90-8C1F-44E3-9860-D744BFCFBA7B",
"Bezeichnung": "Schmuck",
"Kuerzel": "",
"Nummer": "0",
"WareList@xdata.proxy": "Warengruppe(865C6A90-8C1F-44E3-9860-D744BFCFBA7B)/WareList",
"Ware": null
},
{
"$id": 6,
"WarengruppeID": "C6572296-4CE9-4AA3-887C-F9DA0A796680",
"Bezeichnung": "Sonstiges",
"Kuerzel": "",
"Nummer": "0",
"WareList@xdata.proxy": "Warengruppe(C6572296-4CE9-4AA3-887C-F9DA0A796680)/WareList",
"Ware@xdata.ref": "Ware(00000001-0000-0000-0000-000000673739)"
}
]
}
Where is the problem?
Thomas