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

feat(cli) created pg setting auto explain format #2991

Merged
merged 3 commits into from
Sep 20, 2024

Conversation

brahyt-sf
Copy link
Contributor

@brahyt-sf brahyt-sf commented Aug 26, 2024

GUS item: https://gus.lightning.force.com/lightning/r/ADM_Work__c/a07EE00001yRu4CYAS/view

This change will allow the customer to set the auto explain format. To be released with work specified in https://salesforce.quip.com/LKrbARg3mg1g with an announcement.

set text

🕙[ 12:34:41 ] ❯ bin/run pg:settings:auto-explain:log-format postgresql-dbright-crystalline-65397 text -a brahyt-dev
auto-explain.log-format has been set to text for postgresql-dbright-crystalline-65397.
Auto explain log output will log in text format.


2024-08-26T19:36:22.000000+00:00 app[postgres.3188942]: [DBRIGHT_WHITE] [40-2]  Query Text: SELECT setting FROM pg_settings WHERE name = 'data_checksums'
2024-08-26T19:36:22.000000+00:00 app[postgres.3188942]: [DBRIGHT_WHITE] [40-3]  Function Scan on pg_catalog.pg_show_all_settings a  (cost=0.00..3.50 rows=5 width=32) (actual time=3.281..3.320 rows=1 loops=1)
2024-08-26T19:36:22.000000+00:00 app[postgres.3188942]: [DBRIGHT_WHITE] [40-4]    Output: a.setting
2024-08-26T19:36:22.000000+00:00 app[postgres.3188942]: [DBRIGHT_WHITE] [40-5]    Function Call: pg_show_all_settings()
2024-08-26T19:36:22.000000+00:00 app[postgres.3188942]: [DBRIGHT_WHITE] [40-6]    Filter: (a.name = 'data_checksums'::text)
2024-08-26T19:36:22.000000+00:00 app[postgres.3188942]: [DBRIGHT_WHITE] [40-7]    Rows Removed by Filter: 383
2024-08-26T19:36:22.000000+00:00 app[postgres.3188942]: [DBRIGHT_WHITE] [40-8]  Query Identifier: 2247467723989480173

set json

🕙[ 12:34:49 ] ➜ bin/run pg:settings:auto-explain:log-format postgresql-dbright-crystalline-65397 json -a brahyt-dev
auto-explain.log-format has been set to json for postgresql-dbright-crystalline-65397.
Auto explain log output will log in json format.

2024-08-26T19:52:23.000000+00:00 app[postgres.3190672]: [DBRIGHT_WHITE] [42-2]  {
2024-08-26T19:52:23.000000+00:00 app[postgres.3190672]: [DBRIGHT_WHITE] [42-3]    "Query Text": "SELECT setting FROM pg_settings WHERE name = 'data_checksums'",
2024-08-26T19:52:23.000000+00:00 app[postgres.3190672]: [DBRIGHT_WHITE] [42-4]    "Plan": {
2024-08-26T19:52:23.000000+00:00 app[postgres.3190672]: [DBRIGHT_WHITE] [42-5]      "Node Type": "Function Scan",
2024-08-26T19:52:23.000000+00:00 app[postgres.3190672]: [DBRIGHT_WHITE] [42-6]      "Parallel Aware": false,
2024-08-26T19:52:23.000000+00:00 app[postgres.3190672]: [DBRIGHT_WHITE] [42-7]      "Async Capable": false,
2024-08-26T19:52:23.000000+00:00 app[postgres.3190672]: [DBRIGHT_WHITE] [42-8]      "Function Name": "pg_show_all_settings",
2024-08-26T19:52:23.000000+00:00 app[postgres.3190672]: [DBRIGHT_WHITE] [42-9]      "Schema": "pg_catalog",
2024-08-26T19:52:23.000000+00:00 app[postgres.3190672]: [DBRIGHT_WHITE] [42-10]             "Alias": "a",
2024-08-26T19:52:23.000000+00:00 app[postgres.3190672]: [DBRIGHT_WHITE] [42-11]             "Startup Cost": 0.00,
2024-08-26T19:52:23.000000+00:00 app[postgres.3190672]: [DBRIGHT_WHITE] [42-12]             "Total Cost": 3.50,
2024-08-26T19:52:23.000000+00:00 app[postgres.3190672]: [DBRIGHT_WHITE] [42-13]             "Plan Rows": 5,
2024-08-26T19:52:23.000000+00:00 app[postgres.3190672]: [DBRIGHT_WHITE] [42-14]             "Plan Width": 32,
2024-08-26T19:52:23.000000+00:00 app[postgres.3190672]: [DBRIGHT_WHITE] [42-15]             "Actual Startup Time": 2.575,
2024-08-26T19:52:23.000000+00:00 app[postgres.3190672]: [DBRIGHT_WHITE] [42-16]             "Actual Total Time": 2.993,
2024-08-26T19:52:23.000000+00:00 app[postgres.3190672]: [DBRIGHT_WHITE] [42-17]             "Actual Rows": 1,
2024-08-26T19:52:23.000000+00:00 app[postgres.3190672]: [DBRIGHT_WHITE] [42-18]             "Actual Loops": 1,
2024-08-26T19:52:23.000000+00:00 app[postgres.3190672]: [DBRIGHT_WHITE] [42-19]             "Output": ["a.setting"],
2024-08-26T19:52:23.000000+00:00 app[postgres.3190672]: [DBRIGHT_WHITE] [42-20]             "Function Call": "pg_show_all_settings()",
2024-08-26T19:52:23.000000+00:00 app[postgres.3190672]: [DBRIGHT_WHITE] [42-21]             "Filter": "(a.name = 'data_checksums'::text)",
2024-08-26T19:52:23.000000+00:00 app[postgres.3190672]: [DBRIGHT_WHITE] [42-22]             "Rows Removed by Filter": 383
2024-08-26T19:52:23.000000+00:00 app[postgres.3190672]: [DBRIGHT_WHITE] [42-23]           },
2024-08-26T19:52:23.000000+00:00 app[postgres.3190672]: [DBRIGHT_WHITE] [42-24]           "Query Identifier": 2247467723989480173
2024-08-26T19:52:23.000000+00:00 app[postgres.3190672]: [DBRIGHT_WHITE] [42-25]         }

set no option

🕙[ 12:52:34 ] ➜ bin/run pg:settings:auto-explain:log-format postgresql-dbright-crystalline-65397 -a brahyt-dev
auto-explain.log-format is set to json for postgresql-dbright-crystalline-65397.
Auto explain log output will log in json format.

set wrong option

🕙[ 12:52:59 ] ➜ bin/run pg:settings:auto-explain:log-format postgresql-dbright-crystalline-65397 nope -a brahyt-dev
 ›   Error: Expected nope to be one of: text, json, yaml, xml
 ›   See more help with --help

help

🕙[ 12:53:35 ] ❯ bin/run pg:settings:auto-explain:log-format postgresql-dbright-crystalline-65397 -h -a brahyt-dev
Selects the EXPLAIN output format to be used.

USAGE
  $ heroku pg:settings:auto-explain:log-format [DATABASE] [VALUE] -a <value> [-r <value>]

FLAGS
  -a, --app=<value>     (required) app to run command against
  -r, --remote=<value>  git remote of app to use

DESCRIPTION
  Selects the EXPLAIN output format to be used.
  The allowed values are text, xml, json, and yaml. The default is text.

@brahyt-sf brahyt-sf force-pushed the create-pg-setting-auto-explain-format branch from b532dc6 to 8df0a56 Compare August 26, 2024 20:26
@brahyt-sf brahyt-sf force-pushed the create-pg-setting-auto-explain-format branch from 8df0a56 to 6be7c0a Compare August 28, 2024 18:34
@brahyt-sf brahyt-sf marked this pull request as ready for review August 28, 2024 18:34
@brahyt-sf brahyt-sf requested a review from a team as a code owner August 28, 2024 18:34
Copy link
Contributor

@sbosio sbosio left a comment

Choose a reason for hiding this comment

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

Just a couple minor copy edits to review, but it's good to go, so I'm approving.

Co-authored-by: Santiago Bosio <santiago.bosio@gmail.com>
@sbosio sbosio merged commit ce086ef into main Sep 20, 2024
8 checks passed
@sbosio sbosio deleted the create-pg-setting-auto-explain-format branch September 20, 2024 20:27
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.

2 participants