-
Notifications
You must be signed in to change notification settings - Fork 488
catalog: index most of pg_authid
#34535
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
Conversation
|
I was hoping querying the fields of A missed optimization or am I missing something? |
55c09cb to
4c98f11
Compare
|
Fixed! This is the plan for the pgbouncer query now: |
3db1108 to
7d6ef3e
Compare
7d6ef3e to
ddbe176
Compare
| rolpassword, | ||
| rolvaliduntil | ||
| FROM mz_internal.pg_authid_core | ||
| LEFT JOIN extra USING (oid)"#, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why a left join on extra and not just a single FROM with additional columns/projections for rolcreaterole and rolcreatedb?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a comment now that explains this, but it's necessary to go from the bad EXPLAIN plan I posted above to the good EXPLAIN plan I also posted above. See also this thread.
ggevay
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
pgbouncer by default queries `pg_authid` to authenticate users. This query is slow because it reads from unindexed sources and computes an expensive dataflow. Ideally we would fix this by indexing it, but that's not possible because two columns are computed using unmaterializable functions. So instead we introduce a new `pg_authid_core` view that excludes these columns and can be indexed. `pg_authid` is then defined on top of this view.
ddbe176 to
ab9131f
Compare
|
TFTRs! |
pgbouncer by default queries
pg_authidto authenticate users. This query is slow because it reads from unindexed sources and computes an expensive dataflow. Ideally we would fix this by indexing it, but that's not possible because two columns are computed using unmaterializable functions. So instead we introduce a newpg_authid_coreview that excludes these columns and can be indexed.pg_authidis then defined on top of this view.The
pg_authidquery is written in a manually decorrelated way. This is necessary to ensure that queries that read frompg_authidbut only materializable fields get optimized to simple lookups into thepg_authid_coreindex. See Slack thread.Motivation
pgbouncer's default auth queries are expensive.
Checklist
$T ⇔ Proto$Tmapping (possibly in a backwards-incompatible way), then it is tagged with aT-protolabel.