Performance issue on dataset query

Hello,

I have got a performance issue on a page which loads data from dataset.

A first query using email is searching data from Table 1
Then information from table 1 is use to query another Table 2 with a setFilter.

Unfortunately, the code is not correct as it is too long to show final information…

Does anyone have an idea how I can improve the below code?

Thanks
Regards,
Pierre-yves Meyer

$w.onReady(function () {

user.getEmail().then((email) => {
let userEmail = email;
$w(“#email”).text = userEmail;
// Selection company
wixData.query(“clientDataset”) //select the client
.eq(“userStatus”, “active”)
.contains(“title”, userEmail)
.find()
.then((results) => {
let items = results.items;
let company = items[0].userCompany; //select company from client
console.log(items);
// Selection flights per company
$w(“#flightDataset”).setFilter(wixData.filter() //select final data
.contains(“userCompany”, company)
.hasSome(“flightStatus”, “submitted”, “confirmed”)
.ne(“flightVisible”, “N”)
)
.then(() => {
console.log(“Flights Dataset is now filtered”);
})
.catch((err) => {
console.log(err);
});
})
.catch((err) => {
let errorMsg = err;
console.log(errorMsg);
});
});
});

Hi,
Please send your editor’s URL so we can inspect.

Hi Or,

here is the url: www.think4jet.com/flight-modification

For some reason I have often slowness on dataset request. Sounds like when I have imbrication with 2 dataset, wix does not succeed to read my data. Even dataset size are small…

Thanks
Regards,
Pym

Hello Pierre,

It should take no longer than 0.5 seconds for the code to finish processing.
Do you experiencing longer loading times? If so please create a screen cast to illustrate it.

To create a better experience for your users you can hide the table behind a loading box until the data is ready.
See the tutorial here

I have an increasing number of issue on loading times this last days.
Even when requesting directly a dataset or just modifify a value in a dataset via the dashboard.
Here are the errors I meet:

504:Gateway Timeout
Data Load Failed: An error has occured. Check your internet connection and try again
Loading Data… (freeze with no answer)

Any ideas what’s going on ?

Thanks for your help. I am reading the tutorial, I will try the preload solution…

Regards,
pym

Hi Ido,

I still often get the issue I can easily reproduced it in sand box.
I am quite under pressure as from now on I am in production and clients starts to use the application and are unable to submit orders…

when clicking on a validate button on the page modification

export function buttonValidateFlight_click(event, $w) {

//Mise a jour des champs modifiés via item (pb direct connect to DB…)
itemObj.copilotName = $w(“#pilotDropdown”).value;
itemObj.flightStatus = $w(“#statusDropdown”).value;
itemObj.commentPilot = $w(“#textBoxPilotComments”).value;
itemObj.flightCategory = $w(“#categoryDropdown”).value;
itemObj.flightVisible = $w(“#visibleDropdown”).value;

wixData.save(“flightDataset”, itemObj)
.then((results) => {
let item = results;
console.log(item);
wixLocation.to(“/admin”);
})
.catch((err) => {
let errorMsg = err;
console.log(errorMsg);
});

I can see in the dev console =>

Unhandled promise rejection 504: Gateway Timeout
504: Gateway Timeout

s/<
https://f5de7aaa-9142-405f-bda3-4557c2c05615.dev.wix-code.com/_partials/santa/1.3141.36/node_modules/santa-wix-code/dist/wixcode-worker.js:1:98023
e.exports.extendConsoleError/r.error
https://static.parastorage.com/services/dbsm-viewer-app/1.225.0/app.js:6:2835
onUnhandled/</abrupt<
https://static.parastorage.com/services/wix-code-platform/1.31.0/es6runtime.min.js:4:51
perform
https://static.parastorage.com/services/wix-code-platform/1.31.0/es6runtime.min.js:3:30811
onUnhandled/<
https://static.parastorage.com/services/wix-code-platform/1.31.0/es6runtime.min.js:3:31796
[44]</module.exports
https://static.parastorage.com/services/wix-code-platform/1.31.0/es6runtime.min.js:1:20814

https://static.parastorage.com/services/wix-code-platform/1.31.0/es6runtime.min.js:2:12521
run
https://static.parastorage.com/services/wix-code-platform/1.31.0/es6runtime.min.js:2:12309
listener
https://static.parastorage.com/services/wix-code-platform/1.31.0/es6runtime.min.js:2:12345

Any idea what’s going on ?
Many thanks for your help…
regards,
pym