I’m trying to figure out why on CB server 5.5.1 this parameterized query:
{
"statement": "SELECT COUNT(type) AS count, type, MAX(content.updatedAt) AS lastUpdatedAt FROM master WHERE type IS NOT MISSING AND ANY c IN channels SATISFIES c IN $channels END GROUP BY type ORDER BY type",
"$channels": ["denim_all_stores", "denim_location_161", "denim_tax_retail_location_group_33741"]
}
Takes 10x longer to execute than this query with the same parameters embedded:
{
"statement": "SELECT COUNT(type) AS count, type, MAX(content.updatedAt) AS lastUpdatedAt FROM master WHERE type IS NOT MISSING AND ANY c IN channels SATISFIES c IN ['denim_all_stores', 'denim_location_161', 'denim_tax_retail_location_group_33741'] END GROUP BY type ORDER BY type"
}
The index is:
CREATE INDEX `idx_document_metrics` ON `master`((all (`channels`)),`type`,(`content`.`updatedAt`))
I also tried creating a prepared statement and executing it, which had about the same performance as the parameterized query.
The queries return exactly the same results. I’ve attached the execution plan from EXPLAIN for both.
explain.zip (2.5 KB)
I’d appreciate any pointers on this. I need to be able to use parameterized queries, but the performance is inadequate.