backend_firefox: improve length(url) performace

The SQLite builtin function `length()` calculates the number of
Unicode code points of the given argument, while `octet_length()`
calculates the number of bytes.

The two functions should produce the same result for a URL since it's
always ASCII-only, however, with `octet_length()` the length can be
directly fetched from metadata without actually reading the URL text,
thereby improving performance.
This commit is contained in:
CismonX 2025-02-27 14:26:24 +08:00
parent 0307140980
commit 348f13df02
No known key found for this signature in database
GPG key ID: 3094873E29A482FB

View file

@ -2091,7 +2091,7 @@ bookmark_do_list (
"WHERE `b`.`parent` = ? AND `b`.`position` >= ? ORDER BY `b`.`position`"
#define BOOKMARK_LIST_NOJOIN_(col) BOOKMARK_LIST_(col ", `b`.`fk` ", )
#define BOOKMARK_LIST_EX_COLS_ \
"length(`p`.`url`), `b`.`lastModified`, `p`.`last_visit_date`"
"octet_length(`p`.`url`), `b`.`lastModified`, `p`.`last_visit_date`"
#define BOOKMARK_LIST_EX_(col) \
BOOKMARK_LIST_(col ", " BOOKMARK_LIST_EX_COLS_ " ", \
"LEFT JOIN `moz_places` `p` ON `b`.`fk` = `p`.`id` ")
@ -2181,7 +2181,7 @@ bookmark_do_lookup (
) {
#define BOOKMARK_LOOKUP_(join, where) \
"SELECT `b`.`id`, `b`.`lastModified`, " \
"`p`.`last_visit_date`, length(`p`.`url`) " \
"`p`.`last_visit_date`, octet_length(`p`.`url`) " \
"FROM `moz_bookmarks` `b` " \
join "JOIN `moz_places` `p` ON `b`.`fk` = `p`.`id` WHERE " where
#define BOOKMARK_LOOKUP_ASSOC_(col) \