mirror of
https://github.com/maplibre/martin.git
synced 2024-12-18 20:31:54 +03:00
Use ORDERBY in calc_agg_tiles_hash - SQLite v3.44 (#1156)
Require SQLite v3.44+ ORDER BY clause inside aggregate function instead of the windowing one - might solve out of memory issues reported by users - see #1154
This commit is contained in:
parent
c4af48bba9
commit
74c67a3812
@ -72,7 +72,7 @@ serde_with = "3"
|
||||
serde_yaml = "0.9"
|
||||
size_format = "1.0.2"
|
||||
spreet = { version = "0.11", default-features = false }
|
||||
sqlite-hashes = { version = "0.6", default-features = false, features = ["md5", "window", "hex"] }
|
||||
sqlite-hashes = { version = "0.6", default-features = false, features = ["md5", "window", "hex"] } # window forces libsqlite3-sys to bundle sqlite3. We require v3.44.0 or newer.
|
||||
sqlx = { version = "0.7", features = ["sqlite", "runtime-tokio"] }
|
||||
subst = { version = "0.3", features = ["yaml"] }
|
||||
thiserror = "1"
|
||||
|
@ -470,22 +470,18 @@ where
|
||||
// `md5` functions will fail if the value is not text/blob/null
|
||||
//
|
||||
// Note that ORDER BY controls the output ordering, which is important for the hash value,
|
||||
// and having it at the top level would not order values properly.
|
||||
// and we must use ORDER BY as a parameter to the aggregate function itself (available since SQLite 3.44.0)
|
||||
// See https://sqlite.org/forum/forumpost/228bb96e12a746ce
|
||||
"
|
||||
SELECT coalesce(
|
||||
(SELECT md5_concat_hex(
|
||||
md5_concat_hex(
|
||||
cast(zoom_level AS text),
|
||||
cast(tile_column AS text),
|
||||
cast(tile_row AS text),
|
||||
tile_data
|
||||
)
|
||||
OVER (ORDER BY zoom_level, tile_column, tile_row ROWS
|
||||
BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
|
||||
FROM tiles
|
||||
LIMIT 1),
|
||||
md5_hex('')
|
||||
);
|
||||
ORDER BY zoom_level, tile_column, tile_row),
|
||||
md5_hex(''))
|
||||
FROM tiles;
|
||||
",
|
||||
);
|
||||
Ok(query.fetch_one(conn).await?.get::<String, _>(0))
|
||||
|
Loading…
Reference in New Issue
Block a user