{"push_id":1032250615,"size":1,"distinct_size":1,"ref":"refs/heads/index-sel-limit","head":"9ece68131d035e23d9ed59cccdcdfda52ef54372","before":"56b9366bdb95b5217abbf636734e9ee2a18c8e10","commits":[{"sha":"9ece68131d035e23d9ed59cccdcdfda52ef54372","author":{"email":"ec1657b07dda0ff6262dc7efd2e7e3cc188a9ea2@gmail.com","name":"Radu Berinde"},"message":"sql: prefer order-matching index if there is a limit\n\nIn #4925, we observed ineffective planning for a query in the photos app. We\nprefer to use the primary index and sort rather than use a non-covering index\nwhich makes sense in general (non-covering indices require an expensive\nindexJoin) but in this case we also had a limit. In such a case using the index\nwould require looking only at the first rows instead of getting all matching\nrows and sorting.\n\nIn this change we tweak the index selection: if we have a reasonable limit, we\ngive a \"boost\" to all indices that match the ordering exactly. The boost exactly\noffsets the non-covering index penalty.\n\nIn addition to the new tests, I also verified the photo app query in #4925 now\nuses the index.\n\nFixes #5246.","distinct":true,"url":"https://api.github.com/repos/RaduBerinde/cockroach/commits/9ece68131d035e23d9ed59cccdcdfda52ef54372"}]}