Back

Update Document taking absurdly long

  • 1
  • Self Hosted
  • Databases
portmapping
15 Mar, 2025, 20:03

I'm making a food ordering app for businesses

What im trying to do is to create a menu a restuarant is going to have posted all troughout the week, with certain dishes owned by restaurant Here is the createMenu function and what it does is get the restaurants current menu's and just add a new one to the list but the update of the menu inside the restaurants takes an absurdly 15 seconds. There is not even much info on the database.

It cannot be network related cause the Web and the Database are in my machine

declare type Menu = { $id: string; name: string; dishes: Dish[]; };

declare type Restaurant = { $id: string; name: string; rnc: string; phoneNumber: string; logo: string; orders: Order[]; dishes: Dish[]; sucursales: Sucursal[]; clients: Business[]; menus: Menu[]; };

export const createMenu = async ({ name, dishes, restaurant, }: { name: string; dishes: string[]; restaurant: Restaurant; }) => { const startTime = performance.now(); // Start measuring

const { database } = await createAdminClient(); console.log( createAdminClient execution time: ${performance.now() - startTime} ms );

const menuStartTime = performance.now(); const menuResponse = await database.createDocument( DATABASE_ID!, MENU_COLLECTION_ID!, ID.unique(), { name: name, dishes: dishes, } ); console.log( "createDocument execution time: ${performance.now() - menuStartTime} ms" );

const menuId = menuResponse.$id;

const updatedMenus = restaurant.menus ? [...restaurant.menus, menuId] : [menuId];

const updateStartTime = performance.now(); await database.updateDocument( DATABASE_ID!, RESTAURANT_COLLECTION_ID!, restaurant.$id, { menus: updatedMenus, } ); console.log( "updateDocument execution time: ${performance.now() - updateStartTime} ms" );

console.log("Total execution time: ${performance.now() - startTime} ms"); return menuResponse; };

TL;DR
Developers are experiencing slow performance when updating a document for a food ordering app. The issue is not network related as both the Web and the Database are on the same machine. One potential solution could be to check for any default rate limits in Appwrite. It takes 15 seconds to update the menu, even though the database is not overly populated. The code snippet provided includes functions for creating a menu and updating a document. There might be room for improvement in the database update process for better performance.
portmapping
15 Mar, 2025, 20:04

Could it be some rate limits that are set in appwrite by default?

portmapping
15 Mar, 2025, 20:04

if so, how can I disable them

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more