Slow N1QL execution in golang code with GOCB but runs fast in cbq

48 views
Skip to first unread message

Joe,Yu

unread,
May 6, 2016, 4:41:50 AM5/6/16
to couc...@googlegroups.com
Hi ,

i have one N1QL query that query the bucket via created GSI index. And i found the execution speed are vital different when run it in code or in cbq.

The code are written in golang with GOCB as below:

myQuery:=gocb.NewN1qlQuery(SELECT xxxxxx query statement)

no other operation before or after and it use nearly 1 min to finished.

When manually execute the exact same query in cbq, it finished in 44 ms ! 

Below are the explain result of the query, it uses the GSI index.

cbq> explain select `timestamp`,`value` from `monitor` where endpoint='52833dc7331f080e7f589247f36805be0007aa80622ec989e21f0b7972923f23' and metric='host.cpu_usage' and timestamp >1462476751 and timestamp <1462501485;
{
    "requestID": "2ad5be3e-5d7e-4e8e-8d18-69893a9849d4",
    "signature": "json",
    "results": [
        {
            "#operator": "Sequence",
            "~children": [
                {
                    "#operator": "IndexScan",
                    "index": "hostindex1",
                    "keyspace": "monitor",
                    "namespace": "default",
                    "spans": [
                        {
                            "Range": {
                                "High": [
                                    "\"52833dc7331f080e7f589247f36805be0007aa80622ec989e21f0b7972923f23\"",
                                    "\"host.cpu_usage\"",
                                    "1462501485"
                                ],
                                "Inclusion": 0,
                                "Low": [
                                    "\"52833dc7331f080e7f589247f36805be0007aa80622ec989e21f0b7972923f23\"",
                                    "\"host.cpu_usage\"",
                                    "1462476751"
                                ]
                            }
                        }
                    ],
                    "using": "gsi"
                },
                {
                    "#operator": "Parallel",
                    "~child": {
                        "#operator": "Sequence",
                        "~children": [
                            {
                                "#operator": "Fetch",
                                "keyspace": "monitor",
                                "namespace": "default"
                            },
                            {
                                "#operator": "Filter",
                                "condition": "(((((`monitor`.`endpoint`) = \"52833dc7331f080e7f589247f36805be0007aa80622ec989e21f0b7972923f23\") and ((`monitor`.`metric`) = \"host.cpu_usage\")) and (1462476751 \u003c (`monitor`.`timestamp`))) and ((`monitor`.`timestamp`) \u003c 1462501485))"
                            },
                            {
                                "#operator": "InitialProject",
                                "result_terms": [
                                    {
                                        "expr": "(`monitor`.`timestamp`)"
                                    },
                                    {
                                        "expr": "(`monitor`.`value`)"
                                    }
                                ]
                            },
                            {
                                "#operator": "FinalProject"
                            }
                        ]
                    }
                }
            ]
        }
    ],
    "status": "success",
    "metrics": {
        "elapsedTime": "14.492699ms",
        "executionTime": "14.439993ms",
        "resultCount": 1,
        "resultSize": 2650
    }
}
Thanks if anyone know this issues or any clue. 


--
jOe
Reply all
Reply to author
Forward
0 new messages