<!-- 
RSS generated by JIRA (1001.0.0-SNAPSHOT#100246-sha1:7a5c50119eb0633d306e14180817ddef5e80c75d) at Thu Feb 08 23:16:52 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary add field=key&field=summary to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>FOLIO Jira</title>
    <link>https://folio-org.atlassian.net</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>1001.0.0-SNAPSHOT</version>
        <build-number>100246</build-number>
        <build-date>07-02-2024</build-date>
    </build-info>

<item>
            <title>[FOLIO-1920] SPIKE: optimize query instance by location</title>
                <link>https://folio-org.atlassian.net/browse/FOLIO-1920</link>
                <project id="10290" key="FOLIO">FOLIO</project>
                    <description>&lt;p&gt;When query instance by location, following query is generated but the performance is very poor. Query explain analyze shows about &lt;b&gt;50 seconds&lt;/b&gt;. Find a way to improve existing query, or come up a different and better query, or propose other solution like re-organize how instance/holdings data are stored. BTW, the query is generated when users click the Inventory app and select a location filter. Note, I adjusted the &lt;b&gt;~&lt;/b&gt; to &lt;b&gt;LIKE&lt;/b&gt; for the location condition, otherwise, it takes about &lt;b&gt;8 minutes&lt;/b&gt;.&lt;/p&gt;

&lt;p&gt;Note: No implementation in the scope of this ticket.&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
WITH headrecords AS 
(
  SELECT
    jsonb,
    lower(f_unaccent(jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;title&apos;&lt;/span&gt;)) AS title 
  FROM
    supertenant_mod_inventory_storage.instance_holding_view 
  WHERE
    (
(((lower(f_unaccent(instance_holding_view.jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;title&apos;&lt;/span&gt;)) ~ lower(f_unaccent(&lt;span class=&quot;code-quote&quot;&gt;&apos;(^|[[:punct:]]|[[:space:]]|(?=[[:punct:]]|[[:space:]])).*($|[[:punct:]]|[[:space:]]|(?&amp;lt;=[[:punct:]]|[[:space:]]))&apos;&lt;/span&gt;))) 
      OR 
      (
        lower(f_unaccent(instance_holding_view.jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;contributors&apos;&lt;/span&gt;)) ~ lower(f_unaccent(&lt;span class=&quot;code-quote&quot;&gt;&apos;(^|[[:punct:]]|[[:space:]]|(?=[[:punct:]]|[[:space:]]))&lt;span class=&quot;code-quote&quot;&gt;&quot;name&quot;&lt;/span&gt;:([[:punct:]]|[[:space:]])+&lt;span class=&quot;code-quote&quot;&gt;&quot;.*&quot;&lt;/span&gt;($|[[:punct:]]|[[:space:]]|(?&amp;lt;=[[:punct:]]|[[:space:]]))&apos;&lt;/span&gt;)) 
      )
) 
      OR 
      (
        lower(f_unaccent(instance_holding_view.jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;identifiers&apos;&lt;/span&gt;)) ~ lower(f_unaccent(&lt;span class=&quot;code-quote&quot;&gt;&apos;(^|[[:punct:]]|[[:space:]]|(?=[[:punct:]]|[[:space:]]))&lt;span class=&quot;code-quote&quot;&gt;&quot;value&quot;&lt;/span&gt;:([[:punct:]]|[[:space:]])+&lt;span class=&quot;code-quote&quot;&gt;&quot;.*&quot;&lt;/span&gt;($|[[:punct:]]|[[:space:]]|(?&amp;lt;=[[:punct:]]|[[:space:]]))&apos;&lt;/span&gt;)) 
      )
) 
      AND 
      (
        lower(f_unaccent(instance_holding_view.ho_jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;permanentLocationId&apos;&lt;/span&gt;)) LIKE lower(f_unaccent(&lt;span class=&quot;code-quote&quot;&gt;&apos;53cf956f-c1df-410b-8bea-27f712cca7c0&apos;&lt;/span&gt;)) 
      )
    )
    AND lower(f_unaccent(jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;title&apos;&lt;/span&gt;)) &amp;lt; ( 
    SELECT
      lower(f_unaccent(jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;title&apos;&lt;/span&gt;)) 
    FROM
      supertenant_mod_inventory_storage.instance_holding_view 
    ORDER BY
      lower(f_unaccent(jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;title&apos;&lt;/span&gt;)) OFFSET 10000 LIMIT 1 ) 
    ORDER BY
      lower(f_unaccent(jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;title&apos;&lt;/span&gt;)) LIMIT 30 OFFSET 0 
)
,
allrecords AS 
(
  SELECT
    jsonb,
    lower(f_unaccent(jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;title&apos;&lt;/span&gt;)) AS title 
  FROM
    supertenant_mod_inventory_storage.instance_holding_view 
  WHERE
    (
(((lower(f_unaccent(instance_holding_view.jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;title&apos;&lt;/span&gt;)) ~ lower(f_unaccent(&lt;span class=&quot;code-quote&quot;&gt;&apos;(^|[[:punct:]]|[[:space:]]|(?=[[:punct:]]|[[:space:]])).*($|[[:punct:]]|[[:space:]]|(?&amp;lt;=[[:punct:]]|[[:space:]]))&apos;&lt;/span&gt;))) 
      OR 
      (
        lower(f_unaccent(instance_holding_view.jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;contributors&apos;&lt;/span&gt;)) ~ lower(f_unaccent(&lt;span class=&quot;code-quote&quot;&gt;&apos;(^|[[:punct:]]|[[:space:]]|(?=[[:punct:]]|[[:space:]]))&lt;span class=&quot;code-quote&quot;&gt;&quot;name&quot;&lt;/span&gt;:([[:punct:]]|[[:space:]])+&lt;span class=&quot;code-quote&quot;&gt;&quot;.*&quot;&lt;/span&gt;($|[[:punct:]]|[[:space:]]|(?&amp;lt;=[[:punct:]]|[[:space:]]))&apos;&lt;/span&gt;)) 
      )
) 
      OR 
      (
        lower(f_unaccent(instance_holding_view.jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;identifiers&apos;&lt;/span&gt;)) ~ lower(f_unaccent(&lt;span class=&quot;code-quote&quot;&gt;&apos;(^|[[:punct:]]|[[:space:]]|(?=[[:punct:]]|[[:space:]]))&lt;span class=&quot;code-quote&quot;&gt;&quot;value&quot;&lt;/span&gt;:([[:punct:]]|[[:space:]])+&lt;span class=&quot;code-quote&quot;&gt;&quot;.*&quot;&lt;/span&gt;($|[[:punct:]]|[[:space:]]|(?&amp;lt;=[[:punct:]]|[[:space:]]))&apos;&lt;/span&gt;)) 
      )
) 
      AND 
      (
        lower(f_unaccent(instance_holding_view.ho_jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;permanentLocationId&apos;&lt;/span&gt;)) LIKE lower(f_unaccent(&lt;span class=&quot;code-quote&quot;&gt;&apos;53cf956f-c1df-410b-8bea-27f712cca7c0&apos;&lt;/span&gt;)) 
      )
    )
    AND 
    (
      SELECT
        COUNT(*) 
      FROM
        headrecords 
    )
    &amp;lt; 30 
)
SELECT
  jsonb,
  title,
  0 AS count 
FROM
  headrecords 
WHERE
  (
    SELECT
      COUNT(*) 
    FROM
      headrecords 
  )
  &amp;gt;= 30 
UNION
( 
SELECT
  jsonb, title, 
  (
    SELECT
      COUNT(*) 
    FROM
      allrecords 
  )
  AS count 
FROM
  allrecords 
ORDER BY
  title LIMIT 30 OFFSET 0 ) 
ORDER BY
  title;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
</description>
                <environment></environment>
        <key id="81140">FOLIO-1920</key>
            <summary>SPIKE: optimize query instance by location</summary>
                <type id="10003" iconUrl="https://folio-org.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10318?size=medium">Task</type>
                                            <priority id="10002" iconUrl="https://dev.folio.org/assets/jira-priority/jira-p3.svg">P3</priority>
                        <status id="6" iconUrl="https://folio-org.atlassian.net/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="green"/>
                                    <resolution id="10003">Done</resolution>
                                                        <assignee accountid="70121:8d96963c-ce4c-478d-9023-2de35bc14b67">Nassib Nassar</assignee>
                                                                <reporter accountid="557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c">Hongwei Ji</reporter>
                                    <labels>
                            <label>platform-backlog</label>
                    </labels>
                <created>Thu, 28 Mar 2019 13:40:14 +0000</created>
                <updated>Wed, 3 Jun 2020 16:39:40 +0000</updated>
                            <resolved>Thu, 4 Apr 2019 15:26:12 +0000</resolved>
                                                                        <due></due>
                            <votes>0</votes>
                                    <watches>5</watches>
                                                                <comments>
                                                            <comment id="193112" author="70121:8d96963c-ce4c-478d-9023-2de35bc14b67" created="Fri, 29 Mar 2019 04:05:14 +0000"  >&lt;p&gt;Running locally, the query was fast.  HJ suggested changing the &quot;.&lt;b&gt;&quot; term to &quot;.star&lt;/b&gt;&quot; to help reproduce the problem, and this results in the query taking 2m23s running locally.&lt;/p&gt;

&lt;p&gt;The time appears to be spent in CTE &quot;headrecords&quot; (1m11s) which performs a bitmap heap scan on a large number of records.  Disabling the bitmap scan results in the query optimizer using an index scan on holdings_record_permanentlocationid_idx (holdings_record).  This setting is used for the tests below.&lt;/p&gt;

&lt;p&gt;There are 2763587 rows with jsonb-&amp;gt;&amp;gt;&apos;permanentLocationId&apos; = &apos;53cf956f-c1df-410b-8bea-27f712cca7c0&apos; (95% of the rows in holdings_record).  If the query is modified to use jsonb-&amp;gt;&amp;gt;&apos;permanentLocationId&apos; = &apos;fcd64ce1-6995-48f0-840e-89ffa2288371&apos; (of which there are only 36451 rows), running time drops to below 1 second.  This suggests query optimization should focus on the case where the query value for permanentLocationId matches a large number of rows in holdings_record.&lt;/p&gt;</comment>
                                                            <comment id="193117" author="70121:8d96963c-ce4c-478d-9023-2de35bc14b67" created="Mon, 1 Apr 2019 23:51:12 +0000"  >&lt;p&gt;After further debugging, it seems that regular expression queries in the CTEs are running as sequential scans which take most of the time:&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;... ~ lower(f_unaccent(&apos;(^|[[:punct:]]|[[:space:]]|(?=[[:punct:]]|[[:space:]])).star*($|[[:punct:]]|[[:space:]]|(?&amp;lt;=[[:punct:]]|[[:space:]]))&apos;))
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This form of query is possibly being generated to detect word boundaries in order to match only whole words.  It is unclear why the GIN indexes are not used by the query optimizer in this case.&lt;/p&gt;

&lt;p&gt;Using tsvector/tsquery may be an alternative, if it meets the use case requirements:&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;to_tsvector(...) @@ &apos;star&apos;::tsquery
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                                                            <comment id="193121" author="70121:8d96963c-ce4c-478d-9023-2de35bc14b67" created="Tue, 2 Apr 2019 02:27:22 +0000"  >&lt;p&gt;First tests with tsvector/tsquery indicate that it is very fast, but more context about the use case is needed.&lt;/p&gt;</comment>
                                                            <comment id="193125" author="557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c" created="Tue, 2 Apr 2019 14:03:24 +0000"  >&lt;p&gt;&lt;a href=&quot;https://folio-org.atlassian.net/secure/ViewProfile.jspa?accountId=70121%3A8d96963c-ce4c-478d-9023-2de35bc14b67&quot; class=&quot;user-hover&quot; rel=&quot;70121:8d96963c-ce4c-478d-9023-2de35bc14b67&quot; data-account-id=&quot;70121:8d96963c-ce4c-478d-9023-2de35bc14b67&quot; accountid=&quot;70121:8d96963c-ce4c-478d-9023-2de35bc14b67&quot; rel=&quot;noreferrer&quot;&gt;Nassib Nassar&lt;/a&gt;, can you paste/attach the full query that performs better? I thought the FK was the bottleneck.&lt;/p&gt;</comment>
                                                            <comment id="193127" author="70121:8d96963c-ce4c-478d-9023-2de35bc14b67" created="Tue, 2 Apr 2019 14:28:19 +0000"  >&lt;p&gt;This is a test using tsquery on &quot;star&quot;:&lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;/*
CREATE INDEX ON supertenant_mod_inventory_storage.instance USING GIN
    ( to_tsvector(&apos;simple&apos;::regconfig, jsonb -&amp;gt;&amp;gt; &apos;contributors&apos;::text) );
CREATE INDEX ON supertenant_mod_inventory_storage.instance USING GIN
    ( to_tsvector(&apos;simple&apos;::regconfig, jsonb -&amp;gt;&amp;gt; &apos;identifiers&apos;::text) );
ANALYZE supertenant_mod_inventory_storage.instance;
*/
WITH headrecords AS 
(
  SELECT
    jsonb,
    lower(f_unaccent(jsonb -&amp;gt;&amp;gt; &apos;title&apos;)) AS title 
  FROM
    supertenant_mod_inventory_storage.instance_holding_view 
  WHERE
    (
(((to_tsvector(&apos;simple&apos;::regconfig, jsonb -&amp;gt;&amp;gt; &apos;title&apos;::text) @@ &apos;star&apos;::tsquery)
      OR 
      (
	to_tsvector(&apos;simple&apos;::regconfig, jsonb -&amp;gt;&amp;gt; &apos;contributors&apos;::text) @@ &apos;star&apos;::tsquery
      )
) 
      OR 
      (
	to_tsvector(&apos;simple&apos;::regconfig, jsonb -&amp;gt;&amp;gt; &apos;identifiers&apos;::text) @@ &apos;star&apos;::tsquery
      )
) 
      AND 
      (
        lower(f_unaccent(instance_holding_view.ho_jsonb -&amp;gt;&amp;gt; &apos;permanentLocationId&apos;)) LIKE lower(f_unaccent(&apos;53cf956f-c1df-410b-8bea-27f712cca7c0&apos;)) 
      )
    )
    AND lower(f_unaccent(jsonb -&amp;gt;&amp;gt; &apos;title&apos;)) &amp;lt; ( 
    SELECT
      lower(f_unaccent(jsonb -&amp;gt;&amp;gt; &apos;title&apos;)) 
    FROM
      supertenant_mod_inventory_storage.instance_holding_view 
    ORDER BY
      lower(f_unaccent(jsonb -&amp;gt;&amp;gt; &apos;title&apos;)) OFFSET 10000 LIMIT 1 ) 
    ORDER BY
      lower(f_unaccent(jsonb -&amp;gt;&amp;gt; &apos;title&apos;)) LIMIT 30 OFFSET 0 
)
,
allrecords AS 
(
  SELECT
    jsonb,
    lower(f_unaccent(jsonb -&amp;gt;&amp;gt; &apos;title&apos;)) AS title 
  FROM
    supertenant_mod_inventory_storage.instance_holding_view 
  WHERE
    (
(((to_tsvector(&apos;simple&apos;::regconfig, jsonb -&amp;gt;&amp;gt; &apos;title&apos;::text) @@ &apos;star&apos;::tsquery)
      OR 
      (
	to_tsvector(&apos;simple&apos;::regconfig, jsonb -&amp;gt;&amp;gt; &apos;contributors&apos;::text) @@ &apos;star&apos;::tsquery
      )
) 
      OR 
      (
	to_tsvector(&apos;simple&apos;::regconfig, jsonb -&amp;gt;&amp;gt; &apos;identifiers&apos;::text) @@ &apos;star&apos;::tsquery
      )
) 
      AND 
      (
        lower(f_unaccent(instance_holding_view.ho_jsonb -&amp;gt;&amp;gt; &apos;permanentLocationId&apos;)) LIKE lower(f_unaccent(&apos;53cf956f-c1df-410b-8bea-27f712cca7c0&apos;)) 
      )
    )
    AND 
    (
      SELECT
        COUNT(*) 
      FROM
        headrecords 
    )
    &amp;lt; 30 
)
SELECT
  jsonb,
  title,
  0 AS count 
FROM
  headrecords 
WHERE
  (
    SELECT
      COUNT(*) 
    FROM
      headrecords 
  )
  &amp;gt;= 30 
UNION
( 
SELECT
  jsonb, title, 
  (
    SELECT
      COUNT(*) 
    FROM
      allrecords 
  )
  AS count 
FROM
  allrecords 
ORDER BY
  title LIMIT 30 OFFSET 0 ) 
ORDER BY
  title;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                                                            <comment id="193133" author="557058:b8e64633-1f7c-402d-9caf-9959a5ba5d0d" created="Tue, 2 Apr 2019 18:18:31 +0000"  >&lt;p&gt;&lt;a href=&quot;https://folio-org.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; class=&quot;user-hover&quot; rel=&quot;557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; data-account-id=&quot;557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; accountid=&quot;557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; rel=&quot;noreferrer&quot;&gt;Hongwei Ji&lt;/a&gt; &lt;a href=&quot;https://folio-org.atlassian.net/secure/ViewProfile.jspa?accountId=70121%3A8d96963c-ce4c-478d-9023-2de35bc14b67&quot; class=&quot;user-hover&quot; rel=&quot;70121:8d96963c-ce4c-478d-9023-2de35bc14b67&quot; data-account-id=&quot;70121:8d96963c-ce4c-478d-9023-2de35bc14b67&quot; accountid=&quot;70121:8d96963c-ce4c-478d-9023-2de35bc14b67&quot; rel=&quot;noreferrer&quot;&gt;Nassib Nassar&lt;/a&gt; What is the culprit here? From what I can see the clause that is responsible for filtering by location does not use any regexes ( LIKE  lower(f_unaccent(&apos;53cf956f-c1df-410b-8bea-27f712cca7c0&apos;)) and should be fast. The problem seems to be with the title search that uses the regex match when it SHOULD use the fulltext matching (afaik the fulltext index is enabled for &quot;title&quot; in the mod-inventory-storage schema.json)&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://folio-org.atlassian.net/secure/ViewProfile.jspa?accountId=70121%3A8d96963c-ce4c-478d-9023-2de35bc14b67&quot; class=&quot;user-hover&quot; rel=&quot;70121:8d96963c-ce4c-478d-9023-2de35bc14b67&quot; data-account-id=&quot;70121:8d96963c-ce4c-478d-9023-2de35bc14b67&quot; accountid=&quot;70121:8d96963c-ce4c-478d-9023-2de35bc14b67&quot; rel=&quot;noreferrer&quot;&gt;Nassib Nassar&lt;/a&gt; can you please verify when we are not seeing fulltext queries (tsvesctor/tsquery) generated for the title search when location filtering is enabled. It will required looking at the code in RMB and CQL2PG/ Is this something you can do?&lt;/p&gt;</comment>
                                                            <comment id="193138" author="70121:8d96963c-ce4c-478d-9023-2de35bc14b67" created="Tue, 2 Apr 2019 18:32:43 +0000"  >&lt;p&gt;1) Yes, &quot;title&quot;, &quot;contributors&quot;, and &quot;identifiers&quot; are all using regular expressions which are not using the indexes.  Those are the regular expressions I was referring to.  In the revised query using tsquery which I posted above, all three regular expressions have been replaced by tsquery/tsvector queries, bringing the running time from 2m23s to less than 1s.&lt;/p&gt;

&lt;p&gt;2) Yes, but it would save a lot of time if someone that knows the RMB, CQL2PG and relevant module source codes can walk me through them and offer sufficient context, since I have not spent any time ramping up on them.  Otherwise the database layer is much easier for me to contribute in.&lt;/p&gt;</comment>
                                                            <comment id="193146" author="557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c" created="Tue, 2 Apr 2019 20:03:16 +0000"  >&lt;p&gt;&lt;a href=&quot;https://folio-org.atlassian.net/secure/ViewProfile.jspa?accountId=70121%3A8d96963c-ce4c-478d-9023-2de35bc14b67&quot; class=&quot;user-hover&quot; rel=&quot;70121:8d96963c-ce4c-478d-9023-2de35bc14b67&quot; data-account-id=&quot;70121:8d96963c-ce4c-478d-9023-2de35bc14b67&quot; accountid=&quot;70121:8d96963c-ce4c-478d-9023-2de35bc14b67&quot; rel=&quot;noreferrer&quot;&gt;Nassib Nassar&lt;/a&gt;, the same query takes much longer for me in perf env even after adding the new full text indexes.&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
folio=# \d supertenant_mod_inventory_storage.instance;
...
    &lt;span class=&quot;code-quote&quot;&gt;&quot;instance_to_tsvector_idx&quot;&lt;/span&gt; gin (to_tsvector(&lt;span class=&quot;code-quote&quot;&gt;&apos;simple&apos;&lt;/span&gt;::regconfig, jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;contributors&apos;&lt;/span&gt;::text))
    &lt;span class=&quot;code-quote&quot;&gt;&quot;instance_to_tsvector_idx1&quot;&lt;/span&gt; gin (to_tsvector(&lt;span class=&quot;code-quote&quot;&gt;&apos;simple&apos;&lt;/span&gt;::regconfig, jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;identifiers&apos;&lt;/span&gt;::text))
...
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; 
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
 Sort  (cost=3949680.02..3949680.08 rows=23 width=72) (actual time=28979.723..28979.724 rows=30 loops=1)
   Sort Key: &lt;span class=&quot;code-quote&quot;&gt;&quot;*SELECT* 1&quot;&lt;/span&gt;.title
   Sort Method: quicksort  Memory: 67kB
   CTE headrecords
     -&amp;gt;  Limit  (cost=3883614.87..3883614.89 rows=6 width=882) (actual time=14484.151..14484.152 rows=2 loops=1)
           InitPlan 1 (returns $1)
             -&amp;gt;  Limit  (cost=3816349.30..3816730.94 rows=1 width=32) (actual time=223.278..223.279 rows=1 loops=1)
                   -&amp;gt;  Nested Loop  (cost=1.37..1110040518.33 rows=2908646 width=32) (actual time=0.113..222.755 rows=10001 loops=1)
                         -&amp;gt;  Index Scan using instance_title_idx on instance  (cost=0.56..1429603.63 rows=2762804 width=850) (actual time=0.030..42.604 rows=
9693 loops=1)
                         -&amp;gt;  Index Scan using holdings_record_instanceid_idx on holdings_record  (cost=0.81..255.56 rows=14543 width=350) (actual time=0.012.
.0.012 rows=1 loops=9693)
                               Index Cond: (lower(f_unaccent((jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;instanceId&apos;&lt;/span&gt;::text))) = lower(f_unaccent((instance.jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;id&apos;&lt;/span&gt;::text))))
           -&amp;gt;  Sort  (cost=66883.93..66883.95 rows=6 width=882) (actual time=14484.150..14484.150 rows=2 loops=1)
                 Sort Key: (lower(f_unaccent((instance_1.jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;title&apos;&lt;/span&gt;::text))))
                 Sort Method: quicksort  Memory: 28kB
                 -&amp;gt;  Hash Join  (cost=16236.66..66883.86 rows=6 width=882) (actual time=5169.755..14484.141 rows=2 loops=1)
                       Hash Cond: (lower(f_unaccent((holdings_record_1.jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;instanceId&apos;&lt;/span&gt;::text))) = lower(f_unaccent((instance_1.jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;id&apos;&lt;/span&gt;::text)))
)
                       -&amp;gt;  Bitmap Heap Scan on holdings_record holdings_record_1  (cost=533.26..47415.86 rows=14543 width=350) (actual time=217.233..7782.060
 rows=2763587 loops=1)
                             Filter: (lower(f_unaccent((jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;permanentLocationId&apos;&lt;/span&gt;::text))) ~~ &lt;span class=&quot;code-quote&quot;&gt;&apos;53cf956f-c1df-410b-8bea-27f712cca7c0&apos;&lt;/span&gt;::text)
                             Rows Removed by Filter: 93697
                             Heap Blocks: exact=54267 lossy=98820
                             -&amp;gt;  Bitmap Index Scan on holdings_record_permanentlocationid_idx  (cost=0.00..529.63 rows=14543 width=0) (actual time=206.863..2
06.863 rows=2763587 loops=1)
                                   Index Cond: (lower(f_unaccent((jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;permanentLocationId&apos;&lt;/span&gt;::text))) = &lt;span class=&quot;code-quote&quot;&gt;&apos;53cf956f-c1df-410b-8bea-27f712cca7c0&apos;&lt;/span&gt;::text)
                       -&amp;gt;  Hash  (cost=15689.59..15689.59 rows=1105 width=850) (actual time=231.100..231.100 rows=2 loops=1)
                             Buckets: 2048  Batches: 1  Memory Usage: 18kB
                             -&amp;gt;  Bitmap Heap Scan on instance instance_1  (cost=85.69..15689.59 rows=1105 width=850) (actual time=225.802..231.024 rows=2 loo
ps=1)
                                   Recheck Cond: ((to_tsvector(&lt;span class=&quot;code-quote&quot;&gt;&apos;simple&apos;&lt;/span&gt;::regconfig, (jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;title&apos;&lt;/span&gt;::text)) @@ &lt;span class=&quot;code-quote&quot;&gt;&apos;&apos;&apos;star&apos;&lt;/span&gt;&lt;span class=&quot;code-quote&quot;&gt;&apos;&apos;::tsquery) OR (to_tsvector(&apos;&lt;/span&gt;simpl
e&lt;span class=&quot;code-quote&quot;&gt;&apos;::regconfig, (jsonb -&amp;gt;&amp;gt; &apos;&lt;/span&gt;contributors&lt;span class=&quot;code-quote&quot;&gt;&apos;::text)) @@ &apos;&lt;/span&gt;&lt;span class=&quot;code-quote&quot;&gt;&apos;&apos;star&apos;&lt;/span&gt;&lt;span class=&quot;code-quote&quot;&gt;&apos;&apos;::tsquery) OR (to_tsvector(&apos;&lt;/span&gt;simple&lt;span class=&quot;code-quote&quot;&gt;&apos;::regconfig, (jsonb -&amp;gt;&amp;gt; &apos;&lt;/span&gt;identifiers&lt;span class=&quot;code-quote&quot;&gt;&apos;::text)) @@ &apos;&lt;/span&gt;&lt;span class=&quot;code-quote&quot;&gt;&apos;&apos;star&apos;&lt;/span&gt;&apos;&apos;:
:tsquery))
                                   Filter: (lower(f_unaccent((jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;title&apos;&lt;/span&gt;::text))) &amp;lt; $1)
                                   Rows Removed by Filter: 900
                                   Heap Blocks: exact=884
                                   -&amp;gt;  BitmapOr  (cost=85.69..85.69 rows=3315 width=0) (actual time=0.194..0.194 rows=0 loops=1)
                                         -&amp;gt;  Bitmap Index Scan on instance_title_idx_ft  (cost=0.00..29.32 rows=1243 width=0) (actual time=0.142..0.143 rows=
846 loops=1)
                                               Index Cond: (to_tsvector(&lt;span class=&quot;code-quote&quot;&gt;&apos;simple&apos;&lt;/span&gt;::regconfig, (jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;title&apos;&lt;/span&gt;::text)) @@ &lt;span class=&quot;code-quote&quot;&gt;&apos;&apos;&apos;star&apos;&lt;/span&gt;&apos;&apos;::tsquery)
                                         -&amp;gt;  Bitmap Index Scan on instance_to_tsvector_idx  (cost=0.00..29.32 rows=1243 width=0) (actual time=0.031..0.031 ro
ws=86 loops=1)
                                               Index Cond: (to_tsvector(&lt;span class=&quot;code-quote&quot;&gt;&apos;simple&apos;&lt;/span&gt;::regconfig, (jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;contributors&apos;&lt;/span&gt;::text)) @@ &lt;span class=&quot;code-quote&quot;&gt;&apos;&apos;&apos;star&apos;&lt;/span&gt;&apos;&apos;::tsquery)
                                         -&amp;gt;  Bitmap Index Scan on instance_to_tsvector_idx1  (cost=0.00..26.22 rows=829 width=0) (actual time=0.019..0.019 ro
ws=0 loops=1)
                                               Index Cond: (to_tsvector(&lt;span class=&quot;code-quote&quot;&gt;&apos;simple&apos;&lt;/span&gt;::regconfig, (jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;identifiers&apos;&lt;/span&gt;::text)) @@ &lt;span class=&quot;code-quote&quot;&gt;&apos;&apos;&apos;star&apos;&lt;/span&gt;&apos;&apos;::tsquery)
   CTE allrecords
     -&amp;gt;  Result  (cost=15412.47..66062.57 rows=17 width=882) (actual time=232.841..14492.653 rows=915 loops=1)
           One-Time Filter: ($3 &amp;lt; 30)
           InitPlan 3 (returns $3)
             -&amp;gt;  Aggregate  (cost=0.14..0.15 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=1)
                   -&amp;gt;  CTE Scan on headrecords headrecords_1  (cost=0.00..0.12 rows=6 width=0) (actual time=0.000..0.001 rows=2 loops=1)
           -&amp;gt;  Hash Join  (cost=15412.47..66062.57 rows=17 width=882) (actual time=232.836..14492.194 rows=915 loops=1)
                 Hash Cond: (lower(f_unaccent((holdings_record_2.jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;instanceId&apos;&lt;/span&gt;::text))) = lower(f_unaccent((instance_2.jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;id&apos;&lt;/span&gt;::text))))
                 -&amp;gt;  Bitmap Heap Scan on holdings_record holdings_record_2  (cost=533.26..47415.86 rows=14543 width=350) (actual time=213.747..7894.179 rows=
2763587 loops=1)
                       Filter: (lower(f_unaccent((jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;permanentLocationId&apos;&lt;/span&gt;::text))) ~~ &lt;span class=&quot;code-quote&quot;&gt;&apos;53cf956f-c1df-410b-8bea-27f712cca7c0&apos;&lt;/span&gt;::text)
                       Rows Removed by Filter: 93697
                       Heap Blocks: exact=54267 lossy=98820
                       -&amp;gt;  Bitmap Index Scan on holdings_record_permanentlocationid_idx  (cost=0.00..529.63 rows=14543 width=0) (actual time=203.450..203.450
 rows=2763587 loops=1)
                             Index Cond: (lower(f_unaccent((jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;permanentLocationId&apos;&lt;/span&gt;::text))) = &lt;span class=&quot;code-quote&quot;&gt;&apos;53cf956f-c1df-410b-8bea-27f712cca7c0&apos;&lt;/span&gt;::text)
                 -&amp;gt;  Hash  (cost=14837.63..14837.63 rows=3314 width=850) (actual time=7.514..7.514 rows=902 loops=1)
                       Buckets: 4096  Batches: 1  Memory Usage: 824kB
                       -&amp;gt;  Bitmap Heap Scan on instance instance_2  (cost=87.35..14837.63 rows=3314 width=850) (actual time=0.290..4.810 rows=902 loops=1)
                             Recheck Cond: ((to_tsvector(&lt;span class=&quot;code-quote&quot;&gt;&apos;simple&apos;&lt;/span&gt;::regconfig, (jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;title&apos;&lt;/span&gt;::text)) @@ &lt;span class=&quot;code-quote&quot;&gt;&apos;&apos;&apos;star&apos;&lt;/span&gt;&lt;span class=&quot;code-quote&quot;&gt;&apos;&apos;::tsquery) OR (to_tsvector(&apos;&lt;/span&gt;simple&apos;::re
gconfig, (jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;contributors&apos;&lt;/span&gt;::text)) @@ &lt;span class=&quot;code-quote&quot;&gt;&apos;&apos;&apos;star&apos;&lt;/span&gt;&lt;span class=&quot;code-quote&quot;&gt;&apos;&apos;::tsquery) OR (to_tsvector(&apos;&lt;/span&gt;simple&lt;span class=&quot;code-quote&quot;&gt;&apos;::regconfig, (jsonb -&amp;gt;&amp;gt; &apos;&lt;/span&gt;identifiers&lt;span class=&quot;code-quote&quot;&gt;&apos;::text)) @@ &apos;&lt;/span&gt;&lt;span class=&quot;code-quote&quot;&gt;&apos;&apos;star&apos;&lt;/span&gt;&apos;&apos;::tsque
ry))
                             Heap Blocks: exact=884
                             -&amp;gt;  BitmapOr  (cost=87.35..87.35 rows=3315 width=0) (actual time=0.203..0.203 rows=0 loops=1)
                                   -&amp;gt;  Bitmap Index Scan on instance_title_idx_ft  (cost=0.00..29.32 rows=1243 width=0) (actual time=0.147..0.147 rows=846 lo
ops=1)
                                         Index Cond: (to_tsvector(&lt;span class=&quot;code-quote&quot;&gt;&apos;simple&apos;&lt;/span&gt;::regconfig, (jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;title&apos;&lt;/span&gt;::text)) @@ &lt;span class=&quot;code-quote&quot;&gt;&apos;&apos;&apos;star&apos;&lt;/span&gt;&apos;&apos;::tsquery)
                                   -&amp;gt;  Bitmap Index Scan on instance_to_tsvector_idx  (cost=0.00..29.32 rows=1243 width=0) (actual time=0.033..0.033 rows=86
loops=1)
                                         Index Cond: (to_tsvector(&lt;span class=&quot;code-quote&quot;&gt;&apos;simple&apos;&lt;/span&gt;::regconfig, (jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;contributors&apos;&lt;/span&gt;::text)) @@ &lt;span class=&quot;code-quote&quot;&gt;&apos;&apos;&apos;star&apos;&lt;/span&gt;&apos;&apos;::tsquery)
                                   -&amp;gt;  Bitmap Index Scan on instance_to_tsvector_idx1  (cost=0.00..26.22 rows=829 width=0) (actual time=0.022..0.022 rows=0 l
oops=1)
                                         Index Cond: (to_tsvector(&lt;span class=&quot;code-quote&quot;&gt;&apos;simple&apos;&lt;/span&gt;::regconfig, (jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;identifiers&apos;&lt;/span&gt;::text)) @@ &lt;span class=&quot;code-quote&quot;&gt;&apos;&apos;&apos;star&apos;&lt;/span&gt;&apos;&apos;::tsquery)
   -&amp;gt;  HashAggregate  (cost=1.81..2.04 rows=23 width=72) (actual time=28979.683..28979.688 rows=30 loops=1)
         Group Key: &lt;span class=&quot;code-quote&quot;&gt;&quot;*SELECT* 1&quot;&lt;/span&gt;.jsonb, &lt;span class=&quot;code-quote&quot;&gt;&quot;*SELECT* 1&quot;&lt;/span&gt;.title, ((0)::bigint)
         -&amp;gt;  Append  (cost=0.15..1.63 rows=23 width=72) (actual time=28979.604..28979.612 rows=30 loops=1)
               -&amp;gt;  Subquery Scan on &lt;span class=&quot;code-quote&quot;&gt;&quot;*SELECT* 1&quot;&lt;/span&gt;  (cost=0.15..0.34 rows=6 width=72) (actual time=14484.161..14484.161 rows=0 loops=1)
                     -&amp;gt;  Result  (cost=0.15..0.27 rows=6 width=68) (actual time=14484.160..14484.160 rows=0 loops=1)
                           One-Time Filter: ($6 &amp;gt;= 30)
                           InitPlan 6 (returns $6)
                             -&amp;gt;  Aggregate  (cost=0.14..0.15 rows=1 width=8) (actual time=14484.158..14484.158 rows=1 loops=1)
                                   -&amp;gt;  CTE Scan on headrecords headrecords_2  (cost=0.00..0.12 rows=6 width=0) (actual time=14484.153..14484.155 rows=2 loops
=1)
                           -&amp;gt;  CTE Scan on headrecords  (cost=0.15..0.27 rows=6 width=68) (never executed)
               -&amp;gt;  Limit  (cost=1.08..1.12 rows=17 width=72) (actual time=14495.442..14495.447 rows=30 loops=1)
                     InitPlan 5 (returns $5)
                       -&amp;gt;  Aggregate  (cost=0.38..0.39 rows=1 width=8) (actual time=14261.885..14261.885 rows=1 loops=1)
                             -&amp;gt;  CTE Scan on allrecords allrecords_1  (cost=0.00..0.34 rows=17 width=0) (actual time=0.000..14261.371 rows=915 loops=1)
                     -&amp;gt;  Sort  (cost=0.69..0.73 rows=17 width=72) (actual time=14495.441..14495.442 rows=30 loops=1)
                           Sort Key: allrecords.title
                           Sort Method: top-N heapsort  Memory: 92kB
                           -&amp;gt;  CTE Scan on allrecords  (cost=0.00..0.34 rows=17 width=72) (actual time=14494.732..14494.981 rows=915 loops=1)
 Planning time: 1.312 ms
 Execution time: 28979.925 ms
(82 rows)
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                                                            <comment id="193162" author="70121:8d96963c-ce4c-478d-9023-2de35bc14b67" created="Tue, 2 Apr 2019 20:43:22 +0000"  >&lt;p&gt;&lt;a href=&quot;https://folio-org.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; class=&quot;user-hover&quot; rel=&quot;557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; data-account-id=&quot;557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; accountid=&quot;557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; rel=&quot;noreferrer&quot;&gt;Hongwei Ji&lt;/a&gt; I don&apos;t have access to the perf env system, but would you send the full list of indexes on supertenant_mod_inventory_storage.instance.&lt;/p&gt;</comment>
                                                            <comment id="193166" author="557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c" created="Tue, 2 Apr 2019 20:50:09 +0000"  >&lt;p&gt;&lt;a href=&quot;https://folio-org.atlassian.net/secure/ViewProfile.jspa?accountId=70121%3A8d96963c-ce4c-478d-9023-2de35bc14b67&quot; class=&quot;user-hover&quot; rel=&quot;70121:8d96963c-ce4c-478d-9023-2de35bc14b67&quot; data-account-id=&quot;70121:8d96963c-ce4c-478d-9023-2de35bc14b67&quot; accountid=&quot;70121:8d96963c-ce4c-478d-9023-2de35bc14b67&quot; rel=&quot;noreferrer&quot;&gt;Nassib Nassar&lt;/a&gt;, here you go: &lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
folio=# \d supertenant_mod_inventory_storage.instance;
              Table &lt;span class=&quot;code-quote&quot;&gt;&quot;supertenant_mod_inventory_storage.instance&quot;&lt;/span&gt;
      Column      |           Type           | Collation | Nullable | Default
------------------+--------------------------+-----------+----------+---------
 _id              | uuid                     |           | not &lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt; |
 jsonb            | jsonb                    |           | not &lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt; |
 creation_date    | timestamp with time zone |           |          |
 created_by       | text                     |           |          |
 instancestatusid | uuid                     |           |          |
 modeofissuanceid | uuid                     |           |          |
Indexes:
    &lt;span class=&quot;code-quote&quot;&gt;&quot;instance_pkey&quot;&lt;/span&gt; PRIMARY KEY, btree (_id)
    &lt;span class=&quot;code-quote&quot;&gt;&quot;instance_hrid_idx_unique&quot;&lt;/span&gt; UNIQUE, btree (lower(f_unaccent(jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;hrid&apos;&lt;/span&gt;::text)))
    &lt;span class=&quot;code-quote&quot;&gt;&quot;instance_classifications_idx_gin&quot;&lt;/span&gt; gin (lower(f_unaccent(jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;classifications&apos;&lt;/span&gt;::text)) gin_trgm_ops)
    &lt;span class=&quot;code-quote&quot;&gt;&quot;instance_contributors_idx&quot;&lt;/span&gt; btree (lower(f_unaccent(jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;contributors&apos;&lt;/span&gt;::text)))
    &lt;span class=&quot;code-quote&quot;&gt;&quot;instance_contributors_idx_gin&quot;&lt;/span&gt; gin (lower(f_unaccent(jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;contributors&apos;&lt;/span&gt;::text)) gin_trgm_ops)
    &lt;span class=&quot;code-quote&quot;&gt;&quot;instance_id_idx&quot;&lt;/span&gt; btree (lower(f_unaccent(jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;id&apos;&lt;/span&gt;::text)))
    &lt;span class=&quot;code-quote&quot;&gt;&quot;instance_identifiers_idx_gin&quot;&lt;/span&gt; gin (lower(f_unaccent(jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;identifiers&apos;&lt;/span&gt;::text)) gin_trgm_ops)
    &lt;span class=&quot;code-quote&quot;&gt;&quot;instance_indextitle_idx&quot;&lt;/span&gt; btree (lower(f_unaccent(jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;indexTitle&apos;&lt;/span&gt;::text)))
    &lt;span class=&quot;code-quote&quot;&gt;&quot;instance_indextitle_idx_gin&quot;&lt;/span&gt; gin (lower(f_unaccent(jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;indexTitle&apos;&lt;/span&gt;::text)) gin_trgm_ops)
    &lt;span class=&quot;code-quote&quot;&gt;&quot;instance_instancestatusid_idx_gin&quot;&lt;/span&gt; gin (lower(jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;instanceStatusId&apos;&lt;/span&gt;::text) gin_trgm_ops)
    &lt;span class=&quot;code-quote&quot;&gt;&quot;instance_instancetypeid_idx_ft&quot;&lt;/span&gt; gin (to_tsvector(&lt;span class=&quot;code-quote&quot;&gt;&apos;simple&apos;&lt;/span&gt;::regconfig, jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;instanceTypeId&apos;&lt;/span&gt;::text))
    &lt;span class=&quot;code-quote&quot;&gt;&quot;instance_instancetypeid_idx_gin&quot;&lt;/span&gt; gin (lower(f_unaccent(jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;instanceTypeId&apos;&lt;/span&gt;::text)) gin_trgm_ops)
    &lt;span class=&quot;code-quote&quot;&gt;&quot;instance_languages_idx_ft&quot;&lt;/span&gt; gin (to_tsvector(&lt;span class=&quot;code-quote&quot;&gt;&apos;simple&apos;&lt;/span&gt;::regconfig, jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;languages&apos;&lt;/span&gt;::text))
    &lt;span class=&quot;code-quote&quot;&gt;&quot;instance_modeofissuanceid_idx_gin&quot;&lt;/span&gt; gin (lower(jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;modeOfIssuanceId&apos;&lt;/span&gt;::text) gin_trgm_ops)
    &lt;span class=&quot;code-quote&quot;&gt;&quot;instance_publication_idx&quot;&lt;/span&gt; btree (lower(f_unaccent(jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;publication&apos;&lt;/span&gt;::text)))
    &lt;span class=&quot;code-quote&quot;&gt;&quot;instance_statisticalcodeids_idx&quot;&lt;/span&gt; btree (lower(jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;statisticalCodeIds&apos;&lt;/span&gt;::text))
    &lt;span class=&quot;code-quote&quot;&gt;&quot;instance_subjects_idx_gin&quot;&lt;/span&gt; gin (lower(f_unaccent(jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;subjects&apos;&lt;/span&gt;::text)) gin_trgm_ops)
    &lt;span class=&quot;code-quote&quot;&gt;&quot;instance_title_idx&quot;&lt;/span&gt; btree (lower(f_unaccent(jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;title&apos;&lt;/span&gt;::text)))
    &lt;span class=&quot;code-quote&quot;&gt;&quot;instance_title_idx_ft&quot;&lt;/span&gt; gin (to_tsvector(&lt;span class=&quot;code-quote&quot;&gt;&apos;simple&apos;&lt;/span&gt;::regconfig, jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;title&apos;&lt;/span&gt;::text))
    &lt;span class=&quot;code-quote&quot;&gt;&quot;instance_title_idx_gin&quot;&lt;/span&gt; gin (lower(f_unaccent(jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;title&apos;&lt;/span&gt;::text)) gin_trgm_ops)
    &lt;span class=&quot;code-quote&quot;&gt;&quot;instance_to_tsvector_idx&quot;&lt;/span&gt; gin (to_tsvector(&lt;span class=&quot;code-quote&quot;&gt;&apos;simple&apos;&lt;/span&gt;::regconfig, jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;contributors&apos;&lt;/span&gt;::text))
    &lt;span class=&quot;code-quote&quot;&gt;&quot;instance_to_tsvector_idx1&quot;&lt;/span&gt; gin (to_tsvector(&lt;span class=&quot;code-quote&quot;&gt;&apos;simple&apos;&lt;/span&gt;::regconfig, jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;identifiers&apos;&lt;/span&gt;::text))
Foreign-key constraints:
    &lt;span class=&quot;code-quote&quot;&gt;&quot;instance_instancestatusid_fkey&quot;&lt;/span&gt; FOREIGN KEY (instancestatusid) REFERENCES supertenant_mod_inventory_storage.instance_status(_id)
    &lt;span class=&quot;code-quote&quot;&gt;&quot;instance_modeofissuanceid_fkey&quot;&lt;/span&gt; FOREIGN KEY (modeofissuanceid) REFERENCES supertenant_mod_inventory_storage.mode_of_issuance(_id)
Referenced by:
    TABLE &lt;span class=&quot;code-quote&quot;&gt;&quot;supertenant_mod_inventory_storage.holdings_record&quot;&lt;/span&gt; CONSTRAINT &lt;span class=&quot;code-quote&quot;&gt;&quot;holdings_record_instanceid_fkey&quot;&lt;/span&gt; FOREIGN KEY (instanceid) REFERENCES supertenant_mod_inventory_storage.instance(_id)
    TABLE &lt;span class=&quot;code-quote&quot;&gt;&quot;supertenant_mod_inventory_storage.instance_relationship&quot;&lt;/span&gt; CONSTRAINT &lt;span class=&quot;code-quote&quot;&gt;&quot;instance_relationship_subinstanceid_fkey&quot;&lt;/span&gt; FOREIGN KEY (subinstanceid) REFERENCES supertenant_mod_inventory_storage.instance(_id)
    TABLE &lt;span class=&quot;code-quote&quot;&gt;&quot;supertenant_mod_inventory_storage.instance_relationship&quot;&lt;/span&gt; CONSTRAINT &lt;span class=&quot;code-quote&quot;&gt;&quot;instance_relationship_superinstanceid_fkey&quot;&lt;/span&gt; FOREIGN KEY (superinstanceid) REFERENCES supertenant_mod_inventory_storage.instance(_id)
    TABLE &lt;span class=&quot;code-quote&quot;&gt;&quot;supertenant_mod_inventory_storage.instance_source_marc&quot;&lt;/span&gt; CONSTRAINT &lt;span class=&quot;code-quote&quot;&gt;&quot;instance_source_marc__id_fkey&quot;&lt;/span&gt; FOREIGN KEY (_id) REFERENCES supertenant_mod_inventory_storage.instance(_id)
Triggers:
    set_instance_hrid BEFORE INSERT ON supertenant_mod_inventory_storage.instance FOR EACH ROW EXECUTE PROCEDURE supertenant_mod_inventory_storage.set_instance_hrid()
    set_instance_md_json_trigger BEFORE UPDATE ON supertenant_mod_inventory_storage.instance FOR EACH ROW EXECUTE PROCEDURE supertenant_mod_inventory_storage.set_instance_md_json()
    set_instance_md_trigger BEFORE INSERT ON supertenant_mod_inventory_storage.instance FOR EACH ROW EXECUTE PROCEDURE supertenant_mod_inventory_storage.instance_set_md()
    set_instance_sourcerecordformat BEFORE INSERT OR UPDATE ON supertenant_mod_inventory_storage.instance FOR EACH ROW EXECUTE PROCEDURE supertenant_mod_inventory_storage.set_instance_sourcerecordformat()
    update_instance_references BEFORE INSERT OR UPDATE ON supertenant_mod_inventory_storage.instance FOR EACH ROW EXECUTE PROCEDURE supertenant_mod_inventory_storage.update_instance_references()
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                                                            <comment id="193173" author="70121:8d96963c-ce4c-478d-9023-2de35bc14b67" created="Tue, 2 Apr 2019 20:52:41 +0000"  >&lt;p&gt;&lt;a href=&quot;https://folio-org.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; class=&quot;user-hover&quot; rel=&quot;557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; data-account-id=&quot;557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; accountid=&quot;557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; rel=&quot;noreferrer&quot;&gt;Hongwei Ji&lt;/a&gt; Also the postgres configuration file &quot;postgresql.conf&quot; if possible.&lt;/p&gt;</comment>
                                                            <comment id="193177" author="70121:8d96963c-ce4c-478d-9023-2de35bc14b67" created="Tue, 2 Apr 2019 20:59:30 +0000"  >&lt;p&gt;&lt;a href=&quot;https://folio-org.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; class=&quot;user-hover&quot; rel=&quot;557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; data-account-id=&quot;557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; accountid=&quot;557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; rel=&quot;noreferrer&quot;&gt;Hongwei Ji&lt;/a&gt; Also, if not too much trouble, the output of:&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;\d diku_mod_inventory_storage.holdings_record
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                                                            <comment id="193180" author="557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c" created="Tue, 2 Apr 2019 21:06:20 +0000"  >&lt;p&gt;&lt;a href=&quot;https://folio-org.atlassian.net/secure/ViewProfile.jspa?accountId=70121%3A8d96963c-ce4c-478d-9023-2de35bc14b67&quot; class=&quot;user-hover&quot; rel=&quot;70121:8d96963c-ce4c-478d-9023-2de35bc14b67&quot; data-account-id=&quot;70121:8d96963c-ce4c-478d-9023-2de35bc14b67&quot; accountid=&quot;70121:8d96963c-ce4c-478d-9023-2de35bc14b67&quot; rel=&quot;noreferrer&quot;&gt;Nassib Nassar&lt;/a&gt;, here you go &lt;span class=&quot;nobr&quot;&gt;&lt;a href=&quot;/rest/api/3/attachment/content/64168&quot; title=&quot;postgresql.conf attached to FOLIO-1920&quot; data-attachment-type=&quot;file&quot; data-attachment-name=&quot;postgresql.conf&quot; data-media-services-type=&quot;file&quot; data-media-services-id=&quot;60d13b17-0353-4fe6-9cea-29a638a7625a&quot; rel=&quot;noreferrer&quot;&gt;postgresql.conf&lt;sup&gt;&lt;img class=&quot;rendericon&quot; src=&quot;/images/icons/link_attachment_7.gif&quot; height=&quot;7&quot; width=&quot;7&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/sup&gt;&lt;/a&gt;&lt;/span&gt; and &lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
folio=# \d supertenant_mod_inventory_storage.holdings_record;
            Table &lt;span class=&quot;code-quote&quot;&gt;&quot;supertenant_mod_inventory_storage.holdings_record&quot;&lt;/span&gt;
       Column        |           Type           | Collation | Nullable | Default
---------------------+--------------------------+-----------+----------+---------
 _id                 | uuid                     |           | not &lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt; |
 jsonb               | jsonb                    |           | not &lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt; |
 creation_date       | timestamp with time zone |           |          |
 created_by          | text                     |           |          |
 instanceid          | uuid                     |           |          |
 permanentlocationid | uuid                     |           |          |
 temporarylocationid | uuid                     |           |          |
 holdingstypeid      | uuid                     |           |          |
 callnumbertypeid    | uuid                     |           |          |
 illpolicyid         | uuid                     |           |          |
Indexes:
    &lt;span class=&quot;code-quote&quot;&gt;&quot;holdings_record_pkey&quot;&lt;/span&gt; PRIMARY KEY, btree (_id)
    &lt;span class=&quot;code-quote&quot;&gt;&quot;holdings_record_hrid_idx_unique&quot;&lt;/span&gt; UNIQUE, btree (lower(f_unaccent(jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;hrid&apos;&lt;/span&gt;::text)))
    &lt;span class=&quot;code-quote&quot;&gt;&quot;holdings_record_id_idx&quot;&lt;/span&gt; btree (lower(f_unaccent(jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;id&apos;&lt;/span&gt;::text)))
    &lt;span class=&quot;code-quote&quot;&gt;&quot;holdings_record_instanceid_idx&quot;&lt;/span&gt; btree (lower(f_unaccent(jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;instanceId&apos;&lt;/span&gt;::text)))
    &lt;span class=&quot;code-quote&quot;&gt;&quot;holdings_record_instanceid_idx_gin&quot;&lt;/span&gt; gin (lower(f_unaccent(jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;instanceId&apos;&lt;/span&gt;::text)) gin_trgm_ops)
    &lt;span class=&quot;code-quote&quot;&gt;&quot;holdings_record_permanentlocationid_idx&quot;&lt;/span&gt; btree (lower(f_unaccent(jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;permanentLocationId&apos;&lt;/span&gt;::text)))
    &lt;span class=&quot;code-quote&quot;&gt;&quot;holdings_record_permanentlocationid_idx_gin&quot;&lt;/span&gt; gin (lower(f_unaccent(jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;permanentLocationId&apos;&lt;/span&gt;::text)) gin_trgm_ops)
    &lt;span class=&quot;code-quote&quot;&gt;&quot;holdings_record_temporarylocationid_idx&quot;&lt;/span&gt; btree (lower(f_unaccent(jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;temporaryLocationId&apos;&lt;/span&gt;::text)))
    &lt;span class=&quot;code-quote&quot;&gt;&quot;holdings_record_temporarylocationid_idx_gin&quot;&lt;/span&gt; gin (lower(f_unaccent(jsonb -&amp;gt;&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;temporaryLocationId&apos;&lt;/span&gt;::text)) gin_trgm_ops)
Foreign-key constraints:
    &lt;span class=&quot;code-quote&quot;&gt;&quot;holdings_record_callnumbertypeid_fkey&quot;&lt;/span&gt; FOREIGN KEY (callnumbertypeid) REFERENCES supertenant_mod_inventory_storage.call_number_type(_id)
    &lt;span class=&quot;code-quote&quot;&gt;&quot;holdings_record_holdingstypeid_fkey&quot;&lt;/span&gt; FOREIGN KEY (holdingstypeid) REFERENCES supertenant_mod_inventory_storage.holdings_type(_id)
    &lt;span class=&quot;code-quote&quot;&gt;&quot;holdings_record_illpolicyid_fkey&quot;&lt;/span&gt; FOREIGN KEY (illpolicyid) REFERENCES supertenant_mod_inventory_storage.ill_policy(_id)
    &lt;span class=&quot;code-quote&quot;&gt;&quot;holdings_record_instanceid_fkey&quot;&lt;/span&gt; FOREIGN KEY (instanceid) REFERENCES supertenant_mod_inventory_storage.instance(_id)
    &lt;span class=&quot;code-quote&quot;&gt;&quot;holdings_record_permanentlocationid_fkey&quot;&lt;/span&gt; FOREIGN KEY (permanentlocationid) REFERENCES supertenant_mod_inventory_storage.location(_id)
    &lt;span class=&quot;code-quote&quot;&gt;&quot;holdings_record_temporarylocationid_fkey&quot;&lt;/span&gt; FOREIGN KEY (temporarylocationid) REFERENCES supertenant_mod_inventory_storage.location(_id)
Referenced by:
    TABLE &lt;span class=&quot;code-quote&quot;&gt;&quot;supertenant_mod_inventory_storage.item&quot;&lt;/span&gt; CONSTRAINT &lt;span class=&quot;code-quote&quot;&gt;&quot;item_holdingsrecordid_fkey&quot;&lt;/span&gt; FOREIGN KEY (holdingsrecordid) REFERENCES supertenant_mod_inventory_storage.holdings_record(_id)
Triggers:
    set_holdings_record_hrid BEFORE INSERT ON supertenant_mod_inventory_storage.holdings_record FOR EACH ROW EXECUTE PROCEDURE supertenant_mod_inventory_storage.set_holdings_record_hrid()
    set_holdings_record_md_json_trigger BEFORE UPDATE ON supertenant_mod_inventory_storage.holdings_record FOR EACH ROW EXECUTE PROCEDURE supertenant_mod_inventory_storage.set_holdings_record_md_json()
    set_holdings_record_md_trigger BEFORE INSERT ON supertenant_mod_inventory_storage.holdings_record FOR EACH ROW EXECUTE PROCEDURE supertenant_mod_inventory_storage.holdings_record_set_md()
    update_holdings_record_references BEFORE INSERT OR UPDATE ON supertenant_mod_inventory_storage.holdings_record FOR EACH ROW EXECUTE PROCEDURE supertenant_mod_inventory_storage.update_holdings_record_references()
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                                                            <comment id="193186" author="70121:8d96963c-ce4c-478d-9023-2de35bc14b67" created="Wed, 3 Apr 2019 02:43:07 +0000"  >&lt;p&gt;&lt;a href=&quot;https://folio-org.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; class=&quot;user-hover&quot; rel=&quot;557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; data-account-id=&quot;557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; accountid=&quot;557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; rel=&quot;noreferrer&quot;&gt;Hongwei Ji&lt;/a&gt; Thanks.  Also the outputs of:&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;SELECT version();
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;and&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;SHOW ALL;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then &quot;EXPLAIN ANALYZE&quot; the query again, but just before that set:&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;SET enable_hashjoin TO off;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;(in the same session as the query)&lt;/p&gt;</comment>
                                                            <comment id="193187" author="557058:b8e64633-1f7c-402d-9caf-9959a5ba5d0d" created="Wed, 3 Apr 2019 08:25:44 +0000"  >&lt;p&gt;&lt;a href=&quot;https://folio-org.atlassian.net/secure/ViewProfile.jspa?accountId=5ee89462f7aa140abd82d11d&quot; class=&quot;user-hover&quot; rel=&quot;5ee89462f7aa140abd82d11d&quot; data-account-id=&quot;5ee89462f7aa140abd82d11d&quot; accountid=&quot;5ee89462f7aa140abd82d11d&quot; rel=&quot;noreferrer&quot;&gt;Julian Ladisch&lt;/a&gt; any idea why the &quot;title&quot; search uses regexes and not the fulltext query (tsvector/tsquery) when we apply the location filter? Is there a bug in CQLPG or is this because the view is somehow hardcoded in the mod-inventory-storage?&lt;/p&gt;</comment>
                                                            <comment id="193197" author="70121:8d96963c-ce4c-478d-9023-2de35bc14b67" created="Thu, 4 Apr 2019 00:53:13 +0000"  >&lt;p&gt;&lt;a href=&quot;https://folio-org.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; class=&quot;user-hover&quot; rel=&quot;557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; data-account-id=&quot;557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; accountid=&quot;557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; rel=&quot;noreferrer&quot;&gt;Hongwei Ji&lt;/a&gt; &lt;a href=&quot;https://folio-org.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3Ab8e64633-1f7c-402d-9caf-9959a5ba5d0d&quot; class=&quot;user-hover&quot; rel=&quot;557058:b8e64633-1f7c-402d-9caf-9959a5ba5d0d&quot; data-account-id=&quot;557058:b8e64633-1f7c-402d-9caf-9959a5ba5d0d&quot; accountid=&quot;557058:b8e64633-1f7c-402d-9caf-9959a5ba5d0d&quot; rel=&quot;noreferrer&quot;&gt;Jakub Skoczen&lt;/a&gt; I am not sure why the query is running slowly on the perf env.  From the query plan it looks like one problem is incorrect statistics, though presumably autovacuum is running.  But just to be sure could you do:&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;VACUUM ANALYZE supertenant_mod_inventory_storage.instance;
VACUUM ANALYZE supertenant_mod_inventory_storage.holdings_record;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Then re-explain-analyze the query:&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;BEGIN;
EXPLAIN ANALYZE WITH headrecords AS [the rest of the query . . .]
ROLLBACK;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                                                            <comment id="193204" author="70121:8d96963c-ce4c-478d-9023-2de35bc14b67" created="Thu, 4 Apr 2019 03:00:38 +0000"  >&lt;p&gt;&lt;a href=&quot;https://folio-org.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; class=&quot;user-hover&quot; rel=&quot;557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; data-account-id=&quot;557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; accountid=&quot;557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; rel=&quot;noreferrer&quot;&gt;Hongwei Ji&lt;/a&gt; &lt;a href=&quot;https://folio-org.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3Ab8e64633-1f7c-402d-9caf-9959a5ba5d0d&quot; class=&quot;user-hover&quot; rel=&quot;557058:b8e64633-1f7c-402d-9caf-9959a5ba5d0d&quot; data-account-id=&quot;557058:b8e64633-1f7c-402d-9caf-9959a5ba5d0d&quot; accountid=&quot;557058:b8e64633-1f7c-402d-9caf-9959a5ba5d0d&quot; rel=&quot;noreferrer&quot;&gt;Jakub Skoczen&lt;/a&gt; Also again it might be helpful to see the cost parameters and other settings from&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;SHOW ALL;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;on the perf env.&lt;/p&gt;

&lt;p&gt;Alternatively, is it possible for me to clone the perf env locally?&lt;/p&gt;</comment>
                                                            <comment id="193211" author="557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c" created="Thu, 4 Apr 2019 14:16:20 +0000"  >&lt;p&gt;&lt;a href=&quot;https://folio-org.atlassian.net/secure/ViewProfile.jspa?accountId=70121%3A8d96963c-ce4c-478d-9023-2de35bc14b67&quot; class=&quot;user-hover&quot; rel=&quot;70121:8d96963c-ce4c-478d-9023-2de35bc14b67&quot; data-account-id=&quot;70121:8d96963c-ce4c-478d-9023-2de35bc14b67&quot; accountid=&quot;70121:8d96963c-ce4c-478d-9023-2de35bc14b67&quot; rel=&quot;noreferrer&quot;&gt;Nassib Nassar&lt;/a&gt;, please see slack message how to access the perf db directly. Let me know if you have connection issues.&lt;/p&gt;</comment>
                                                            <comment id="193217" author="70121:8d96963c-ce4c-478d-9023-2de35bc14b67" created="Thu, 4 Apr 2019 15:08:27 +0000"  >&lt;p&gt;On the perf db, after running the two VACUUM ANALYZE commands above to recompile statistics, the query runs in less than one second (~300 ms).&lt;/p&gt;</comment>
                                                            <comment id="193221" author="70121:8d96963c-ce4c-478d-9023-2de35bc14b67" created="Thu, 4 Apr 2019 15:11:38 +0000"  >&lt;p&gt;&lt;a href=&quot;https://folio-org.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; class=&quot;user-hover&quot; rel=&quot;557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; data-account-id=&quot;557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; accountid=&quot;557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; rel=&quot;noreferrer&quot;&gt;Hongwei Ji&lt;/a&gt; Could you run the sequence in &lt;a href=&quot;https://folio-org.atlassian.net/browse/FOLIO-1920?focusedCommentId=193197&amp;amp;page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&quot; class=&quot;external-link&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://folio-org.atlassian.net/browse/FOLIO-1920?focusedCommentId=193197&amp;amp;page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&lt;/a&gt; and see if that works for you?&lt;/p&gt;</comment>
                                                            <comment id="193228" author="70121:8d96963c-ce4c-478d-9023-2de35bc14b67" created="Thu, 4 Apr 2019 15:47:38 +0000"  >&lt;p&gt;Hongwei confirms the query is now very fast.  I have closed this issue.&lt;/p&gt;</comment>
                                                            <comment id="193233" author="557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c" created="Thu, 4 Apr 2019 15:59:42 +0000"  >&lt;p&gt;Just want to add that the original query (regex version) is also fast now. Is it a pure stats issue?&lt;/p&gt;</comment>
                                                            <comment id="193236" author="557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c" created="Thu, 4 Apr 2019 16:27:13 +0000"  >&lt;p&gt;BTW, see this in the perf db starting log:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
2019-04-04 12:06:26.547 UTC [208] ERROR:  canceling autovacuum task
2019-04-04 12:06:26.547 UTC [208] CONTEXT:  automatic analyze of table &lt;span class=&quot;code-quote&quot;&gt;&quot;folio.supertenant_mod_inventory_storage.instance&quot;&lt;/span&gt;
2019-04-04 12:06:30.115 UTC [208] ERROR:  canceling autovacuum task
2019-04-04 12:06:30.115 UTC [208] CONTEXT:  automatic analyze of table &lt;span class=&quot;code-quote&quot;&gt;&quot;folio.supertenant_mod_inventory_storage.holdings_record&quot;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                                                            <comment id="193240" author="70121:8d96963c-ce4c-478d-9023-2de35bc14b67" created="Thu, 4 Apr 2019 19:15:16 +0000"  >&lt;p&gt;Hongwei asks about a related query:&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;SELECT COUNT(*) FROM supertenant_mod_inventory_storage.instance_holding_view  WHERE lower(f_unaccent(instance_holding_view.ho_jsonb-&amp;gt;&amp;gt;&apos;permanentLocationId&apos;)) ~ lower(f_unaccent(&apos;(^|[[:punct:]]|[[:space:]]|(?=[[:punct:]]|[[:space:]])) 53cf956f-c1df-410b-8bea-27f712cca7c0($|[[:punct:]]|[[:space:]]|(?&amp;lt;=[[:punct:]]|[[:space:]]))&apos;));
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I will take a quick look at this.&lt;/p&gt;</comment>
                                                            <comment id="193244" author="70121:8d96963c-ce4c-478d-9023-2de35bc14b67" created="Thu, 4 Apr 2019 20:26:28 +0000"  >&lt;p&gt;Most of the time in this related query is spent in performing the join.  I think the question should be asked whether the join is necessary or if the problem can be reformulated.  Other than that, some performance optimization may be possible.&lt;/p&gt;

&lt;p&gt;A secondary issue is the unnecessary use of a regular expression.  The WHERE clause should use (ho_jsonb-&amp;gt;&amp;gt;&apos;permanentLocationId&apos; = &apos;53cf956f-c1df-410b-8bea-27f712cca7c0&apos;) if that satisfies the use case.&lt;/p&gt;</comment>
                                                            <comment id="193246" author="70121:8d96963c-ce4c-478d-9023-2de35bc14b67" created="Fri, 5 Apr 2019 12:28:55 +0000"  >&lt;p&gt;&lt;a href=&quot;https://folio-org.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; class=&quot;user-hover&quot; rel=&quot;557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; data-account-id=&quot;557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; accountid=&quot;557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c&quot; rel=&quot;noreferrer&quot;&gt;Hongwei Ji&lt;/a&gt; Running locally (VM), the original regex &quot;star&quot; query takes 140.0 s compared with the new tsvector query which takes 0.3 s.  I didn&apos;t investigate the regex query on the perf env, as tsvector would seem a more correct form for the use case.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10000">
                    <name>Blocks</name>
                                            <outwardlinks description="blocks">
                                        <issuelink>
            <issuekey id="55923">MODINVSTOR-256</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                            <issuelinktype id="10003">
                    <name>Relates</name>
                                            <outwardlinks description="relates to">
                                        <issuelink>
            <issuekey id="37516">CQLPG-95</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="55811">MODINVSTOR-185</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="relates to">
                                        <issuelink>
            <issuekey id="55860">MODINVSTOR-273</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                            <attachment id="64168" name="postgresql.conf" size="22796" author="557058:4f6bed01-40a6-48d5-8471-7ef21f5ea97c" created="Tue, 2 Apr 2019 21:05:45 +0000"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10000" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummarycf">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10057" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Development Team</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10144"><![CDATA[Core: Platform]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10019" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>0|hzzkr3:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10020" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="1418">Core: Platform - Sprint 60</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10044" key="com.atlassian.jira.plugin.system.customfieldtypes:float">
                        <customfieldname>Story Points</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>5.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10024" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>[CHART] Date of First Response</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Fri, 29 Mar 2019 04:05:14 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10025" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>[CHART] Time in Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                    </customfields>
    </item>
</channel>
</rss>