{"action":"created","issue":{"url":"https://api.github.com/repos/techfort/LokiJS/issues/663","repository_url":"https://api.github.com/repos/techfort/LokiJS","labels_url":"https://api.github.com/repos/techfort/LokiJS/issues/663/labels{/name}","comments_url":"https://api.github.com/repos/techfort/LokiJS/issues/663/comments","events_url":"https://api.github.com/repos/techfort/LokiJS/issues/663/events","html_url":"https://github.com/techfort/LokiJS/issues/663","id":306684121,"number":663,"title":"bulk remove very slow","user":{"login":"z543","id":3062605,"avatar_url":"https://avatars3.githubusercontent.com/u/3062605?v=4","gravatar_id":"","url":"https://api.github.com/users/z543","html_url":"https://github.com/z543","followers_url":"https://api.github.com/users/z543/followers","following_url":"https://api.github.com/users/z543/following{/other_user}","gists_url":"https://api.github.com/users/z543/gists{/gist_id}","starred_url":"https://api.github.com/users/z543/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/z543/subscriptions","organizations_url":"https://api.github.com/users/z543/orgs","repos_url":"https://api.github.com/users/z543/repos","events_url":"https://api.github.com/users/z543/events{/privacy}","received_events_url":"https://api.github.com/users/z543/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":13,"created_at":"2018-03-20T00:18:47Z","updated_at":"2018-03-24T14:00:37Z","closed_at":null,"author_association":"NONE","body":"I bulk remove item using following code\r\n\r\nthe speed is very fast when size of items less than 50000 (approximate)\r\nand it become very very very slow when size of items large than 60000 (approximate)\r\n\r\n50000 items: 146 ms\r\n60000 items: 14274 ms\r\n\r\nCPU: Intel Core2 Duo E8400 3GHz\r\nRAM: 8GB\r\nWindows 7 x64\r\nChrome 67.0.3371.0 (Official Build) dev (64-bit)\r\n\r\n```js\r\nconst docs = [\r\n  { name: 'mjolnir', owner: 'thor', maker: 'dwarves' },\r\n  { name: 'gungnir', owner: 'odin', maker: 'elves' },\r\n  { name: 'tyrfing', owner: 'Svafrlami', maker: 'dwarves' },\r\n  { name: 'draupnir', owner: 'odin', maker: 'elves' },\r\n]\r\nvar db = new loki('sandbox.db')\r\n// Add a collection to the database\r\nvar items = db.addCollection('items')\r\n\r\nfunction addLokiItems(items, title) {\r\n  console.time(title)\r\n  for (var i = 0; i < 50000; i++) {\r\n    items.insert({ ...docs[0], data: Math.random() })\r\n  }\r\n  console.timeEnd(title)\r\n}\r\n\r\naddLokiItems(items, 'loki-add mem')\r\n\r\nfunction removeLokiItems(items, title) {\r\n  console.time(title)\r\n  var data = items.data\r\n  var idIndex=items.idIndex\r\n  items.findAndRemove({$loki: { '$gte' : 10 }})\r\n  console.timeEnd(title)\r\n}\r\nremoveLokiItems(items, 'loki-remove mem')\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/techfort/LokiJS/issues/comments/375891419","html_url":"https://github.com/techfort/LokiJS/issues/663#issuecomment-375891419","issue_url":"https://api.github.com/repos/techfort/LokiJS/issues/663","id":375891419,"user":{"login":"z543","id":3062605,"avatar_url":"https://avatars3.githubusercontent.com/u/3062605?v=4","gravatar_id":"","url":"https://api.github.com/users/z543","html_url":"https://github.com/z543","followers_url":"https://api.github.com/users/z543/followers","following_url":"https://api.github.com/users/z543/following{/other_user}","gists_url":"https://api.github.com/users/z543/gists{/gist_id}","starred_url":"https://api.github.com/users/z543/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/z543/subscriptions","organizations_url":"https://api.github.com/users/z543/orgs","repos_url":"https://api.github.com/users/z543/repos","events_url":"https://api.github.com/users/z543/events{/privacy}","received_events_url":"https://api.github.com/users/z543/received_events","type":"User","site_admin":false},"created_at":"2018-03-24T14:00:37Z","updated_at":"2018-03-24T14:00:37Z","author_association":"NONE","body":"total 50000 items \r\n\r\n```js\r\nitems.chain().find({type: { $eq: 1 }}).remove()  // 28 ms       \r\nitems.chain().find({type: { $ne: 1 }}).remove()  // 8856 ms   \r\n```\r\nwhy?\r\n"}}
{"actor":{"display_login":"z543"}}