{"action":"created","issue":{"url":"https://api.github.com/repos/couchbaselabs/query/issues/12","repository_url":"https://api.github.com/repos/couchbaselabs/query","labels_url":"https://api.github.com/repos/couchbaselabs/query/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/couchbaselabs/query/issues/12/comments","events_url":"https://api.github.com/repos/couchbaselabs/query/issues/12/events","html_url":"https://github.com/couchbaselabs/query/issues/12","id":190364077,"number":12,"title":"Result slow on n1ql","user":{"login":"kivervinicius","id":4115328,"avatar_url":"https://avatars.githubusercontent.com/u/4115328?v=3","gravatar_id":"","url":"https://api.github.com/users/kivervinicius","html_url":"https://github.com/kivervinicius","followers_url":"https://api.github.com/users/kivervinicius/followers","following_url":"https://api.github.com/users/kivervinicius/following{/other_user}","gists_url":"https://api.github.com/users/kivervinicius/gists{/gist_id}","starred_url":"https://api.github.com/users/kivervinicius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kivervinicius/subscriptions","organizations_url":"https://api.github.com/users/kivervinicius/orgs","repos_url":"https://api.github.com/users/kivervinicius/repos","events_url":"https://api.github.com/users/kivervinicius/events{/privacy}","received_events_url":"https://api.github.com/users/kivervinicius/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-11-18T16:38:59Z","updated_at":"2016-11-18T16:44:59Z","closed_at":null,"body":"In a bank of approximately 300,000 records, the query below:\r\n\r\n```\r\nSELECT count(usuario) FROM analytics where \r\n    datahora.entrada >= '2016-11-18T00:00:00.000Z' and \r\n    datahora.entrada <= '2016-11-18T99:99:99.999Z' limit 5000\r\n```\r\nTakes about 1 min, using n1ql would it be possible to optimize it using indices? I tried to do as below but it did not work\r\n```\r\nCREATE INDEX `ANALYTICS_datahora-entrada` ON `analytics`((`datahora`.`entrada`)) WHERE (`_type` = \"analytics\") USING GSI\r\n```"},"comment":{"url":"https://api.github.com/repos/couchbaselabs/query/issues/comments/261579553","html_url":"https://github.com/couchbaselabs/query/issues/12#issuecomment-261579553","issue_url":"https://api.github.com/repos/couchbaselabs/query/issues/12","id":261579553,"user":{"login":"MikeGoldsmith","id":3481731,"avatar_url":"https://avatars.githubusercontent.com/u/3481731?v=3","gravatar_id":"","url":"https://api.github.com/users/MikeGoldsmith","html_url":"https://github.com/MikeGoldsmith","followers_url":"https://api.github.com/users/MikeGoldsmith/followers","following_url":"https://api.github.com/users/MikeGoldsmith/following{/other_user}","gists_url":"https://api.github.com/users/MikeGoldsmith/gists{/gist_id}","starred_url":"https://api.github.com/users/MikeGoldsmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MikeGoldsmith/subscriptions","organizations_url":"https://api.github.com/users/MikeGoldsmith/orgs","repos_url":"https://api.github.com/users/MikeGoldsmith/repos","events_url":"https://api.github.com/users/MikeGoldsmith/events{/privacy}","received_events_url":"https://api.github.com/users/MikeGoldsmith/received_events","type":"User","site_admin":false},"created_at":"2016-11-18T16:44:59Z","updated_at":"2016-11-18T16:44:59Z","body":"Hi @kivervinicius \r\n\r\nYou could also try using STR_TO_MILLIS function to convert your string to a unix timestamp. Details of available functions are [here](http://developer.couchbase.com/documentation/server/current/n1ql/n1ql-language-reference/datefun.html).\r\n\r\nThe comparison you're doing in your query is doing an ordinal comparison between two string, not a real datetime diff."}}
{"actor":{"display_login":"MikeGoldsmith"}}