{"html_url": "https://github.com/simonw/datasette/pull/2008#issuecomment-1407716963", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/2008", "id": 1407716963, "node_id": "IC_kwDOBm6k_c5T6A5j", "user": {"value": 193185, "label": "cldellow"}, "created_at": "2023-01-29T17:04:03Z", "updated_at": "2023-01-29T17:04:03Z", "author_association": "CONTRIBUTOR", "body": "Performance tests - I think most places don't have them as a formal gate enforced by CI. TypeScript and scalac seem to have tests that run to capture timings. The timings are included by a bot as a comment or build check, and also stored in a database so you can graph changes over time to spot regressions. Probably overkill for Datasette!\r\n\r\nWindow functions - oh, good point. Looks like Ubuntu shipped JSON1 support as far back as sqlite 3.11. I'll let this PR linger until there's a way to run against different SQLite versions. For now, I'm shipping this with `datasette-ui-extras`, since I think it's OK for a plugin to enforce a higher minimum requirement.\r\n\r\nTests - there actually did end up being test changes to capture the undercount bug of the current implementation, so the current implementation would fail against the new tests.\r\n\r\nPerhaps a non-window function version could be written that uses `random()` instead of `row_number() over ()` in order to get a unique key. It's technically not unique, but in practice, I imagine it'll work well.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1560982210, "label": "array facet: don't materialize unnecessary columns"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/2008#issuecomment-1407561308", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/2008", "id": 1407561308, "node_id": "IC_kwDOBm6k_c5T5a5c", "user": {"value": 193185, "label": "cldellow"}, "created_at": "2023-01-29T04:50:50Z", "updated_at": "2023-01-29T04:50:50Z", "author_association": "CONTRIBUTOR", "body": "I pushed a revised version which ends up being faster -- the example which currently takes 4 seconds now runs in 500ms.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1560982210, "label": "array facet: don't materialize unnecessary columns"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/2008#issuecomment-1407558284", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/2008", "id": 1407558284, "node_id": "IC_kwDOBm6k_c5T5aKM", "user": {"value": 193185, "label": "cldellow"}, "created_at": "2023-01-29T04:23:58Z", "updated_at": "2023-01-29T04:24:27Z", "author_association": "CONTRIBUTOR", "body": "Ack, this PR is broken. I see now that the `inner.*` is necessary for ensuring the correct count in the face of rows having duplicate values in views.\r\n\r\nThat fixes the overcounting, but I think can undercount when the rows have the same data, eg a view like:\r\n\r\n```sql\r\nSELECT '[\"bar\"]' tags UNION ALL SELECT '[\"bar\"]'\r\n```\r\n\r\nwill produce a count of `{\"bar\": 1 }`, when it should be `{\"bar\": 2}`. In fact, this could apply in tables without primary keys, too.\r\n\r\nIf `inner` came from a base table that had a primary key or a rowid, we could use those column(s) to solve that case.\r\n\r\nI guess a general solution would be to compute a window function so we have a distinct ID for each row. Will fiddle to see if I can get that working.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1560982210, "label": "array facet: don't materialize unnecessary columns"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/2008#issuecomment-1407470429", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/2008", "id": 1407470429, "node_id": "IC_kwDOBm6k_c5T5Etd", "user": {"value": 193185, "label": "cldellow"}, "created_at": "2023-01-28T19:34:29Z", "updated_at": "2023-01-28T19:34:29Z", "author_association": "CONTRIBUTOR", "body": "I don't know how/if you do automated tests for performance, so I haven't changed any of the tests.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1560982210, "label": "array facet: don't materialize unnecessary columns"}, "performed_via_github_app": null}