mirror of
https://github.com/owntone/owntone-server.git
synced 2025-11-25 20:16:14 -05:00
[db] Speed up Q_PL query used by e.g. '/databases/1/containers' request
The previous solution would use subqueries to count the number of items and streams in each playlist, which means that response time gets pretty slow if there are many playlists. This commit also includes a number of lesser db code changes.
This commit is contained in:
@@ -316,9 +316,9 @@ rsp_reply_info(struct httpd_request *hreq)
|
||||
mxml_node_t *node;
|
||||
cfg_t *lib;
|
||||
char *library;
|
||||
int songcount;
|
||||
uint32_t songcount;
|
||||
|
||||
songcount = db_files_get_count();
|
||||
db_files_get_count(&songcount, NULL, NULL);
|
||||
|
||||
lib = cfg_getsec(cfg, "library");
|
||||
library = cfg_getstr(lib, "name");
|
||||
@@ -347,7 +347,7 @@ rsp_reply_info(struct httpd_request *hreq)
|
||||
|
||||
/* Info block */
|
||||
node = mxmlNewElement(info, "count");
|
||||
mxmlNewTextf(node, 0, "%d", songcount);
|
||||
mxmlNewTextf(node, 0, "%d", (int)songcount);
|
||||
|
||||
node = mxmlNewElement(info, "rsp-version");
|
||||
mxmlNewText(node, 0, RSP_VERSION);
|
||||
@@ -377,7 +377,7 @@ rsp_reply_db(struct httpd_request *hreq)
|
||||
int i;
|
||||
int ret;
|
||||
|
||||
memset(&qp, 0, sizeof(struct db_playlist_info));
|
||||
memset(&qp, 0, sizeof(struct query_params));
|
||||
|
||||
qp.type = Q_PL;
|
||||
qp.idx_type = I_NONE;
|
||||
@@ -414,7 +414,7 @@ rsp_reply_db(struct httpd_request *hreq)
|
||||
mxmlNewTextf(node, 0, "%d", qp.results);
|
||||
|
||||
/* Playlists block (all playlists) */
|
||||
while (((ret = db_query_fetch_pl(&qp, &dbpli, 1)) == 0) && (dbpli.id))
|
||||
while (((ret = db_query_fetch_pl(&qp, &dbpli)) == 0) && (dbpli.id))
|
||||
{
|
||||
/* Playlist block (one playlist) */
|
||||
pl = mxmlNewElement(pls, "playlist");
|
||||
|
||||
Reference in New Issue
Block a user