Query run by the system?

I am seeing a query that is not run by any of our code and looks expensive. Not sure what it is but runs frequently. Anybody knows what is this? Looks like something from couchbase itself.
Couchbase Server Community Edition 5.1.1 build 5723.

select requestTime,statement, array_sum(object_values(phaseCounts)) cost
from system:completed_requests
where array_sum(object_values(phaseCounts)) >100
order by requestTime desc

[
{
“cost”: 120,
“requestTime”: “2019-06-17 21:59:57.811800264 +0000 UTC”,
“statement”: “select max(keyspace_id) id, max(has_primary) has_prim, max(has_second) has_sec, max(secondary_indexes) sec_ind from ( select indexes.keyspace_id, true has_primary from system:indexes where is_primary = true and state = ‘online’ union select indexes.keyspace_id, true has_second, array_agg(indexes.index_key) secondary_indexes from system:indexes where state = ‘online’ and is_primary is missing or is_primary = false group by keyspace_id having keyspace_id is not null union select id keyspace_id from system:keyspaces except (select indexes.keyspace_id from system:indexes where state = ‘online’ union select “” keyspace_id) ) foo group by keyspace_id having keyspace_id is not null order by keyspace_id”
},
{
“cost”: 120,
“requestTime”: “2019-06-17 21:59:57.318632501 +0000 UTC”,
“statement”: “select max(keyspace_id) id, max(has_primary) has_prim, max(has_second) has_sec, max(secondary_indexes) sec_ind from ( select indexes.keyspace_id, true has_primary from system:indexes where is_primary = true and state = ‘online’ union select indexes.keyspace_id, true has_second, array_agg(indexes.index_key) secondary_indexes from system:indexes where state = ‘online’ and is_primary is missing or is_primary = false group by keyspace_id having keyspace_id is not null union select id keyspace_id from system:keyspaces except (select indexes.keyspace_id from system:indexes where state = ‘online’ union select “” keyspace_id) ) foo group by keyspace_id having keyspace_id is not null order by keyspace_id”
},
{
“cost”: 120,
“requestTime”: “2019-06-17 21:59:40.002418557 +0000 UTC”,
“statement”: “select max(keyspace_id) id, max(has_primary) has_prim, max(has_second) has_sec, max(secondary_indexes) sec_ind from ( select indexes.keyspace_id, true has_primary from system:indexes where is_primary = true and state = ‘online’ union select indexes.keyspace_id, true has_second, array_agg(indexes.index_key) secondary_indexes from system:indexes where state = ‘online’ and is_primary is missing or is_primary = false group by keyspace_id having keyspace_id is not null union select id keyspace_id from system:keyspaces except (select indexes.keyspace_id from system:indexes where state = ‘online’ union select “” keyspace_id) ) foo group by keyspace_id having keyspace_id is not null order by keyspace_id”
},
{
“cost”: 120,
“requestTime”: “2019-06-17 21:59:38.499880243 +0000 UTC”,
“statement”: “select max(keyspace_id) id, max(has_primary) has_prim, max(has_second) has_sec, max(secondary_indexes) sec_ind from ( select indexes.keyspace_id, true has_primary from system:indexes where is_primary = true and state = ‘online’ union select indexes.keyspace_id, true has_second, array_agg(indexes.index_key) secondary_indexes from system:indexes where state = ‘online’ and is_primary is missing or is_primary = false group by keyspace_id having keyspace_id is not null union select id keyspace_id from system:keyspaces except (select indexes.keyspace_id from system:indexes where state = ‘online’ union select “” keyspace_id) ) foo group by keyspace_id having keyspace_id is not null order by keyspace_id”
},
{
“cost”: 120,
“requestTime”: “2019-06-17 21:59:38.49895961 +0000 UTC”,
“statement”: “select max(keyspace_id) id, max(has_primary) has_prim, max(has_second) has_sec, max(secondary_indexes) sec_ind from ( select indexes.keyspace_id, true has_primary from system:indexes where is_primary = true and state = ‘online’ union select indexes.keyspace_id, true has_second, array_agg(indexes.index_key) secondary_indexes from system:indexes where state = ‘online’ and is_primary is missing or is_primary = false group by keyspace_id having keyspace_id is not null union select id keyspace_id from system:keyspaces except (select indexes.keyspace_id from system:indexes where state = ‘online’ union select “” keyspace_id) ) foo group by keyspace_id having keyspace_id is not null order by keyspace_id”
},
{
“cost”: 120,
“requestTime”: “2019-06-17 21:59:34.663731041 +0000 UTC”,
“statement”: “select max(keyspace_id) id, max(has_primary) has_prim, max(has_second) has_sec, max(secondary_indexes) sec_ind from ( select indexes.keyspace_id, true has_primary from system:indexes where is_primary = true and state = ‘online’ union select indexes.keyspace_id, true has_second, array_agg(indexes.index_key) secondary_indexes from system:indexes where state = ‘online’ and is_primary is missing or is_primary = false group by keyspace_id having keyspace_id is not null union select id keyspace_id from system:keyspaces except (select indexes.keyspace_id from system:indexes where state = ‘online’ union select “” keyspace_id) ) foo group by keyspace_id having keyspace_id is not null order by keyspace_id”
}

Look other fields of the system:completed_requests it will give details.

May be these are duet to when you run queries from query monitoring ( link you provided Indexer 100% cpu at random different nodes)

1 Like

silly me, yeap that is the case. When i invoke this query select requestTime,statement, array_sum(object_values(phaseCounts)) cost
from system:completed_requests
where array_sum(object_values(phaseCounts)) >100
order by requestTime desc
looks like ends up been translated like the other one.
Thanks,