Improve profile fetch performance for large groups.

This commit is contained in:
Cody Henthorne
2026-05-19 15:13:35 -04:00
committed by jeffrey-signal
parent d682de08d2
commit 1661f3b5f7
10 changed files with 123 additions and 50 deletions
@@ -307,12 +307,15 @@ object SqlUtil {
* This means chunking isn't necessary for any practical collection length.
*/
@JvmStatic
@JvmOverloads
fun buildFastCollectionQuery(
column: String,
values: Collection<Any?>
values: Collection<Any?>,
prefix: String = ""
): Query {
require(!values.isEmpty()) { "Must have values!" }
return Query("$column IN (SELECT e.value FROM json_each(?) e)", arrayOf(jsonEncode(buildArgs(values))))
val prefixFilter = if (prefix.isEmpty() || prefix.endsWith(" ")) prefix else "$prefix "
return Query("$prefixFilter$column IN (SELECT e.value FROM json_each(?) e)", arrayOf(jsonEncode(buildArgs(values))))
}
/**