Postgres: How to create index concurrently using liquibase











up vote
3
down vote

favorite
1












Looking at the liquibase documention http://www.liquibase.org/documentation/changes/create_index.html, CIC is not possible with create index, as liquibase doesn't have a tag to specify concurrent option.



Is there a way to create index concurrently with liquibase?










share|improve this question






















  • You need a <sql> tag with the appropriate CREATE INDEX statement
    – a_horse_with_no_name
    Mar 15 at 13:26










  • I see this error CREATE INDEX CONCURRENTLY cannot run inside a transaction block. I'm assuming migrations are run in transaction to rollback if necessary. Is there something I'm doing wrong?
    – user4988095
    Mar 15 at 16:30












  • @user4988095 yes, each changeset is executed in transaction
    – dbf
    Mar 17 at 7:23















up vote
3
down vote

favorite
1












Looking at the liquibase documention http://www.liquibase.org/documentation/changes/create_index.html, CIC is not possible with create index, as liquibase doesn't have a tag to specify concurrent option.



Is there a way to create index concurrently with liquibase?










share|improve this question






















  • You need a <sql> tag with the appropriate CREATE INDEX statement
    – a_horse_with_no_name
    Mar 15 at 13:26










  • I see this error CREATE INDEX CONCURRENTLY cannot run inside a transaction block. I'm assuming migrations are run in transaction to rollback if necessary. Is there something I'm doing wrong?
    – user4988095
    Mar 15 at 16:30












  • @user4988095 yes, each changeset is executed in transaction
    – dbf
    Mar 17 at 7:23













up vote
3
down vote

favorite
1









up vote
3
down vote

favorite
1






1





Looking at the liquibase documention http://www.liquibase.org/documentation/changes/create_index.html, CIC is not possible with create index, as liquibase doesn't have a tag to specify concurrent option.



Is there a way to create index concurrently with liquibase?










share|improve this question













Looking at the liquibase documention http://www.liquibase.org/documentation/changes/create_index.html, CIC is not possible with create index, as liquibase doesn't have a tag to specify concurrent option.



Is there a way to create index concurrently with liquibase?







indexing liquibase






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 15 at 13:20









user4988095

163




163












  • You need a <sql> tag with the appropriate CREATE INDEX statement
    – a_horse_with_no_name
    Mar 15 at 13:26










  • I see this error CREATE INDEX CONCURRENTLY cannot run inside a transaction block. I'm assuming migrations are run in transaction to rollback if necessary. Is there something I'm doing wrong?
    – user4988095
    Mar 15 at 16:30












  • @user4988095 yes, each changeset is executed in transaction
    – dbf
    Mar 17 at 7:23


















  • You need a <sql> tag with the appropriate CREATE INDEX statement
    – a_horse_with_no_name
    Mar 15 at 13:26










  • I see this error CREATE INDEX CONCURRENTLY cannot run inside a transaction block. I'm assuming migrations are run in transaction to rollback if necessary. Is there something I'm doing wrong?
    – user4988095
    Mar 15 at 16:30












  • @user4988095 yes, each changeset is executed in transaction
    – dbf
    Mar 17 at 7:23
















You need a <sql> tag with the appropriate CREATE INDEX statement
– a_horse_with_no_name
Mar 15 at 13:26




You need a <sql> tag with the appropriate CREATE INDEX statement
– a_horse_with_no_name
Mar 15 at 13:26












I see this error CREATE INDEX CONCURRENTLY cannot run inside a transaction block. I'm assuming migrations are run in transaction to rollback if necessary. Is there something I'm doing wrong?
– user4988095
Mar 15 at 16:30






I see this error CREATE INDEX CONCURRENTLY cannot run inside a transaction block. I'm assuming migrations are run in transaction to rollback if necessary. Is there something I'm doing wrong?
– user4988095
Mar 15 at 16:30














@user4988095 yes, each changeset is executed in transaction
– dbf
Mar 17 at 7:23




@user4988095 yes, each changeset is executed in transaction
– dbf
Mar 17 at 7:23












2 Answers
2






active

oldest

votes

















up vote
1
down vote













You can specify runInTransaction as false to create the index concurrently.






share|improve this answer




























    up vote
    0
    down vote













    Creating a concurrent index must be done with the arbitrary sql change:



    <changeSet runInTransaction="false" id="10-add-widgets-kind-index" author="username">
    <sql dbms="postgresql">
    CREATE INDEX CONCURRENTLY
    IF NOT EXISTS idx_widgets_kind
    ON widgets(kind)
    </sql>
    </changeSet>


    This is a combination of a_horse_with_no_name's comment and TheDude's answer.






    share|improve this answer





















      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














       

      draft saved


      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f49300553%2fpostgres-how-to-create-index-concurrently-using-liquibase%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      1
      down vote













      You can specify runInTransaction as false to create the index concurrently.






      share|improve this answer

























        up vote
        1
        down vote













        You can specify runInTransaction as false to create the index concurrently.






        share|improve this answer























          up vote
          1
          down vote










          up vote
          1
          down vote









          You can specify runInTransaction as false to create the index concurrently.






          share|improve this answer












          You can specify runInTransaction as false to create the index concurrently.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jun 11 at 19:36









          TheDude

          2,69521940




          2,69521940
























              up vote
              0
              down vote













              Creating a concurrent index must be done with the arbitrary sql change:



              <changeSet runInTransaction="false" id="10-add-widgets-kind-index" author="username">
              <sql dbms="postgresql">
              CREATE INDEX CONCURRENTLY
              IF NOT EXISTS idx_widgets_kind
              ON widgets(kind)
              </sql>
              </changeSet>


              This is a combination of a_horse_with_no_name's comment and TheDude's answer.






              share|improve this answer

























                up vote
                0
                down vote













                Creating a concurrent index must be done with the arbitrary sql change:



                <changeSet runInTransaction="false" id="10-add-widgets-kind-index" author="username">
                <sql dbms="postgresql">
                CREATE INDEX CONCURRENTLY
                IF NOT EXISTS idx_widgets_kind
                ON widgets(kind)
                </sql>
                </changeSet>


                This is a combination of a_horse_with_no_name's comment and TheDude's answer.






                share|improve this answer























                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  Creating a concurrent index must be done with the arbitrary sql change:



                  <changeSet runInTransaction="false" id="10-add-widgets-kind-index" author="username">
                  <sql dbms="postgresql">
                  CREATE INDEX CONCURRENTLY
                  IF NOT EXISTS idx_widgets_kind
                  ON widgets(kind)
                  </sql>
                  </changeSet>


                  This is a combination of a_horse_with_no_name's comment and TheDude's answer.






                  share|improve this answer












                  Creating a concurrent index must be done with the arbitrary sql change:



                  <changeSet runInTransaction="false" id="10-add-widgets-kind-index" author="username">
                  <sql dbms="postgresql">
                  CREATE INDEX CONCURRENTLY
                  IF NOT EXISTS idx_widgets_kind
                  ON widgets(kind)
                  </sql>
                  </changeSet>


                  This is a combination of a_horse_with_no_name's comment and TheDude's answer.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 19 at 0:31









                  sghill

                  42637




                  42637






























                       

                      draft saved


                      draft discarded



















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f49300553%2fpostgres-how-to-create-index-concurrently-using-liquibase%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

                      Alcedinidae

                      Origin of the phrase “under your belt”?