)]}'
{"swift/container/backend.py":[{"author":{"_account_id":7233,"name":"Matthew Oliver","email":"matt@oliver.net.au","username":"mattoliverau"},"change_message_id":"0c851c56a43930240409c9ee2ab845f5edc056f1","unresolved":true,"context_lines":[{"line_number":2243,"context_line":"                # make another query to get the actual number of rows in this"},{"line_number":2244,"context_line":"                # final shard"},{"line_number":2245,"context_line":"                sql \u003d (\u0027SELECT count(name) FROM object WHERE %s\u003d0 \u0027 %"},{"line_number":2246,"context_line":"                       self._get_deleted_key(connection))"},{"line_number":2247,"context_line":"                sql +\u003d sql_extra"},{"line_number":2248,"context_line":"                shard_size \u003d connection.execute(sql, args).fetchone()[0]"},{"line_number":2249,"context_line":"            else:"}],"source_content_type":"text/x-python","patch_set":1,"id":"f482c4c1_74288214","line":2246,"updated":"2021-05-26 07:21:33.000000000","message":"I did have a query that gave us the next upper and the count in the one SQL by doign a sub command... probably end up being just as costly as 2 seperate calls I guess.\n\nHere it is:\n\nselect count(name) as obj_count, max(name) as upper from (select name from object where name \u003e \u003clast_upper\u003e order by name LIMIT \u003cshard_size\u003e);\n\nWhich looks like:\n\nQUERY PLAN\n|--CO-ROUTINE 1\n|  |--SCAN TABLE object USING COVERING INDEX ix_object_deleted_name\n|  `--USE TEMP B-TREE FOR ORDER BY\n`--SCAN SUBQUERY 1\n\nAnd returns a row (500k, \u003cnext_upper\u003e)\n\nWhen it gets to the end it\u0027ll be (200k, \u003clast obj in DB\u003e) so if obj_count in the result \u003c shard_size we return upper as None.\n\nBut no idea which would be faster. Depends on the speed of the second SCAN SUBQUERY. And seems if doing a CO-ROUTINE we need a temp b-tree because when I run it on yours:\n\nQUERY PLAN\n`--SEARCH TABLE object USING COVERING INDEX ix_object_deleted_name (deleted\u003d? AND name\u003e?)\n\nQUERY PLAN\n`--SEARCH TABLE object USING COVERING INDEX ix_object_deleted_name (deleted\u003d? AND name\u003e?)\n\nFirst for the upper then for the count.. although we know from experience (unless it was fixed in sqlite) the offset walk can be expensive even though it doesn\u0027t say it here. But so might the LIMIT (never looked into that one).","commit_id":"ad278881cd0d2a9577bec204ff15b80de6e4d1d5"}]}
