Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: Benchmark has_schema_privilege, has_sequence_privilege, has_table_privilege #75855

Merged
merged 1 commit into from
Feb 17, 2022
Merged

sql: Benchmark has_schema_privilege, has_sequence_privilege, has_table_privilege #75855

merged 1 commit into from
Feb 17, 2022

Conversation

ecwall
Copy link
Contributor

@ecwall ecwall commented Feb 2, 2022

fixes #66173

These builtins have been changed to use HasPrivilege instead of executing SQL
queries internally.

Release notes: None

@ecwall ecwall requested review from otan and a team February 2, 2022 13:30
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@ajwerner
Copy link
Contributor

ajwerner commented Feb 2, 2022

You'll need to update the expectations file. Also, consider adding cases where you set up more than one of each of the things.

// prevents database exists error
Setup: `DROP DATABASE IF EXISTS d; CREATE DATABASE d`,
Stmt: `SELECT has_database_privilege('d', 'CREATE')`,
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add more tests to see how it scales with number of databases/schemas/sequences?

basically, in the setup, it can create multiple entities, and the Stmt to test can be something like

SELECT has_database_privilege(name, 'CREATE') FROM crdb_internal.databases;

for schemas, something like

SELECT has_schema_privilege(nspame, 'CREATE') FROM pg_catalog.pg_namespace

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Talked about the tests not supporting has_database_privilege offline. Updated the others.

@otan otan removed their request for review February 8, 2022 20:26
@ecwall
Copy link
Contributor Author

ecwall commented Feb 9, 2022

Error described in #76296 needs to be resolved

@ecwall ecwall changed the title sql: Benchmark has_database_privilege, has_schema_privilege, has_sequence_privilege sql: Benchmark has_schema_privilege, has_sequence_privilege, has_table_privilege Feb 14, 2022
@ecwall ecwall requested a review from rafiss February 14, 2022 21:44
},

{
Name: "has_schema_privilege multiple",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit instead of multiple, state how many schemas are being created

we should probably test 1,3,5 schemas and see the relative increases

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to create tables/schemas/etc using generate_series (or something similar) to avoid copying and pasting?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can use the sql language to iterate and do multiple DDLs but perhaps you could extend make a helper function to create a string for setup

has_table_privilege

fixes #66173

These builtins have been changed to use HasPrivilege instead of executing SQL
queries internally.

Release note: None
@@ -77,7 +77,7 @@ func runBenchmarkExpectationTests(t *testing.T, r *Registry) {

var results resultSet
var wg sync.WaitGroup
concurrency := ((system.NumCPU()*4 - 1) / r.numNodes) + 1 // arbitrary
concurrency := ((system.NumCPU() - 1) / r.numNodes) + 1 // arbitrary
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spoke with @ajwerner on slack about this. Removing the *4 makes the tests run much faster with larger (>4) rewrite iterations.

Copy link
Contributor

@RichardJCai RichardJCai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Comment on lines +63 to +69
1,ORMQueries/has_schema_privilege_5
2,ORMQueries/has_sequence_privilege_1
4,ORMQueries/has_sequence_privilege_3
6,ORMQueries/has_sequence_privilege_5
2,ORMQueries/has_table_privilege_1
4,ORMQueries/has_table_privilege_3
6,ORMQueries/has_table_privilege_5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤮 😢

@ecwall
Copy link
Contributor Author

ecwall commented Feb 16, 2022

bors r=RichardJCai

@craig
Copy link
Contributor

craig bot commented Feb 16, 2022

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Feb 17, 2022

Build succeeded:

@craig craig bot merged commit 27ed9d6 into cockroachdb:master Feb 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sql: improve perf of has_database_privilege, has_schema_privilege and has_sequence_privilege
5 participants