How to decode encoded_plan?


#1

Hi everyone,

I have some slow prepared and parameterised queries but I am not sure which one is the culprit…

I can have access to the encoded_plan and was wondering if there was a way to use a couchbase tool to decode it and see what is the plan?


#2

We don’t have a direct way to turn the encoded plan into a plan, I’m afraid.

To answer your question from a different angle, in Watson we have implemented a completed request log which will hold all the requests that have run for longer than a preset threshold (which is configurable from either command line or REST).

You can access it via N1QL:

select * from system:completed_requests;

or REST

curl “http://localhost:8093/admin/complete_requests

That would be your first port of call to identify likely culprits.
Since completed_requests gives you the query text (among other things), using EXPLAIN against the text of the slow queries would give you their plans.

We also have a system keyspace listing all prepared statements (with text and encoded_plans) (system:prepareds, or if using REST, the /admin/prepareds endpoint).
Given an encoded plan, you should be able to find the corresponding statement from it, and then tie it back to completed requests.

HTH,
Marco


#3

Many thanks.

Unfortunately, for the moment, I am on 4.1… Looking forward to the 4.5 as this kind of facilities around slow queries will be very helpful!