-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58739 from rafiss/backport20.2-58671
release-20.2: sql: fix performance regression in user authn
- Loading branch information
Showing
3 changed files
with
45 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright 2021 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package bench | ||
|
||
import "testing" | ||
|
||
func BenchmarkSystemDatabaseQueries(b *testing.B) { | ||
tests := []RoundTripBenchTestCase{ | ||
// This query performs 1 extra lookup since the executor first tries to | ||
// lookup the name `current_db.system.users`. | ||
{ | ||
name: "select system.users without schema name", | ||
stmt: `SELECT username, "hashedPassword" FROM system.users WHERE username = 'root'`, | ||
}, | ||
// This query performs 4 extra lookup since the executor tries to | ||
// lookup the name `"".system.users`. Since the "" database doesn't exist, | ||
// it also falls back to looking up that database name in the deprecated | ||
// namespace table. | ||
{ | ||
name: "select system.users with empty database name", | ||
setup: `SET sql_safe_updates = false; USE "";`, | ||
stmt: `SELECT username, "hashedPassword" FROM system.users WHERE username = 'root'`, | ||
}, | ||
// This query performs 2 lookups: getting the descriptor ID by name, then | ||
// fetching the system table descriptor. | ||
{ | ||
name: "select system.users with schema name", | ||
stmt: `SELECT username, "hashedPassword" FROM system.public.users WHERE username = 'root'`, | ||
}, | ||
} | ||
|
||
RunRoundTripBenchmark(b, tests) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters