Skip to content

Conversation

WofWca
Copy link
Collaborator

@WofWca WofWca commented Oct 20, 2025

In Delta Chat desktop we show the 3 recently used WebXDC apps,
which relies on get_chat_media, which is quite expensive.
Hopefully adding LIMIT 3 makes it faster.

https://github.com/deltachat/deltachat-desktop/blob/d32e85ec1353730a512cbdfff6c9c4dba5816dd4/packages/frontend/src/components/screens/MainScreen/MainScreen.tsx#L170-L181

Marking this as a breaking change
because it's breaking TypeScript-wise,
but shouldn't be breaking behavior-wise,
because not providing the argument in JSON-RPC
should be equivalent to providing null
(which gets converted to None).

TODO:

  • Add to CFFI?
  • Docs. Both the core fn and the JSON-RPC.

@WofWca WofWca added jsonrpc cffi regarding the cffi api, similar to the jsonrpc tag labels Oct 20, 2025
In Delta Chat desktop we show the 3 recently used WebXDC apps,
which relies on `get_chat_media`, which is quite expensive.
Hopefully adding `LIMIT 3` makes it faster.

Marking this as a breaking change
because it's breaking TypeScript-wise,
but shouldn't be breaking behavior-wise,
because not providing the argument in JSON-RPC
should be equivalent to providing `null`
(which gets converted to `None`).

TODO:
- [ ] Add to CFFI?
- [ ] Docs. Both the core fn and the JSON-RPC.
@WofWca WofWca force-pushed the wofwca/perf-get_chat_media-limit-option branch from e3728b2 to 781de46 Compare October 20, 2025 15:18
@Simon-Laux
Copy link
Contributor

related to the need to provide null in typescript for Option::None: chatmail/yerpc#10

chat_id.unwrap_or_else(|| ChatId::new(0)),
DC_CHAT_ID_TRASH,
Viewtype::Webxdc,
limit.map(|l| l.to_string()).unwrap_or("ALL".to_string()),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SQLite doesn't support ALL. Looks like we need to omit the parameter somehow. Maybe using format!

@Simon-Laux
Copy link
Contributor

Simon-Laux commented Oct 20, 2025

Alternatively there could be another jsonrpc api just for the purpose of returning the last 3 webxdc apps. jsonrpc apis are easy to create compared to cffi api. (Could potentially be optimized even more than adding an option to the existing api, because it could be implemented differently under the hood)

@r10s
Copy link
Contributor

r10s commented Oct 20, 2025

please do some measurements on some slow chats before merging or diving into details. it is not always the case that a LIMIT makes things significantly faster.

eg. ORDER BY and SELECT may still needed to be done on whole data set; LIMIT is more often useful when it comes to remote connections, less often on local connections. but as said, measurement will tell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cffi regarding the cffi api, similar to the jsonrpc tag jsonrpc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants