8000 Add support for creating partial indexes on tables by kvch · Pull Request #404 · xataio/pgroll · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add support for creating partial indexes on tables #404

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 you 8000 r account

Merged
merged 11 commits into from
Oct 16, 2024

Conversation

kvch
Copy link
Contributor
@kvch kvch commented Oct 15, 2024

This PR adds a new option to create_index operations called predicate. When predicate is the conditional expression of the partial index. When it is set, pgroll creates a partial index on the table.

Example:

{
  "name": "37_create_partial_index",
  "operations": [
    {
      "create_index": {
        "name": "idx_fruits_id_gt_10",
        "table": "fruits",
        "columns": [
          "id"
        ],
        "predicate": "id > 10"
      }
    }
  ]
}

Closes #322

@kvch kvch requested a review from andrew-farries October 15, 2024 15:55
@kvch kvch marked this pull request as draft October 15, 2024 15:56
@kvch kvch marked this pull request as ready for review October 15, 2024 16:01
8000
Co-authored-by: Ryan Slade <ryanslade@gmail.com>
Copy link
Collaborator
@andrew-farries andrew-farries left a comment

Choose a reason for hiding this comment

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

This looks good 👍

We should also update the read_schema SQL function to return information about the predicate of a partial index. Right now the new index from the example looks like this:

{
  "indexes": {
    "idx_fruits_id_gt_10": {
      "name": "idx_fruits_id_gt_10",
      "unique": false,
      "columns": [
        "id"
      ]
    }
  }
}

(this is part of the resulting_schema field after the migration to add the partial index has been applied).

ryanslade and others added 3 commits October 16, 2024 12:46
The previous version was building the pgroll command before every
example run. Instead, build the command once at the beginning and remove
it at the end.
Closes xataio#257

---------

Co-authored-by: Andrew Farries <andyrb@gmail.com>
@kvch
Copy link
Contributor Author
kvch commented Oct 16, 2024

Updated the PR so the output of analyze contains the predicate as well:

"idx_fruits_id_gt_10": {
  "name": "idx_fruits_id_gt_10",
  "unique": false,
  "columns": [
    "id"
  ],
  "predicate": "(id \u003e 10)"
}

@kvch kvch merged commit 0cab124 into xataio:main Oct 16, 2024
26 checks passed
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.

Support for partial indexes
4 participants
0