[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgresql-sql
Subject:    [SQL] Different plan for one query problem
From:       Tatarnikov Alexander <cankrus () gmail ! com>
Date:       2010-10-27 1:50:16
Message-ID: AANLkTi=zzSmk3AL1K4geEq-0sLi8tu6r3cALD=R8UHiH () mail ! gmail ! com
[Download RAW message or body]

Hello!

I have following query:
SELECT
db_oks_zu."tbl_location"."full_address",
db_class."kladrCache"."region",
db_class."kladrCache"."mo",
db_class."kladrCache"."city",
db_class."kladrCache"."street",
db_oks_zu."tbl_location"."house",
db_oks_zu."tbl_position"."number_flat",
((((((COALESCE(db_oks_zu."tbl_powners"."psurname",''))||('
'))||(COALESCE(db_oks_zu."tbl_powners"."pname",'')))||('
'))||(COALESCE(db_oks_zu."tbl_powners"."ppatronimic",'')))||('
'))||(COALESCE(db_oks_zu."tbl_powners"."pnumdoc",'')) as c8,
db_oks_zu."tbl_register"."invent_number",
db_oks_zu."tbl_rights"."share",
db_oks_zu."tbl_objects_main"."date_modifed",
db_oks_zu."tbl_objects_main"."parent_id" FROM
"db_oks_zu"."tbl_powners"
Left JOIN "db_oks_zu"."lnk_owners" ON
"db_oks_zu"."lnk_owners"."powners_id"="db_oks_zu"."tbl_powners"."powners_id"

Left JOIN "db_oks_zu"."tbl_rights" ON
"db_oks_zu"."tbl_rights"."right_id"="db_oks_zu"."lnk_owners"."right_id"
Left JOIN "db_oks_zu"."tbl_objects_main" ON
"db_oks_zu"."tbl_objects_main"."object_id"="db_oks_zu"."tbl_rights"."object_id"

Left JOIN "reestr_base"."fileObjects" ON
"reestr_base"."fileObjects"."objectId"="db_oks_zu"."tbl_objects_main"."object_id"

Left JOIN "reestr_base"."invFiles" ON
"reestr_base"."invFiles"."id"="reestr_base"."fileObjects"."fileId"
Left JOIN "db_oks_zu"."tbl_register" ON
"db_oks_zu"."tbl_register"."object_id"="db_oks_zu"."tbl_objects_main"."object_id"

Left JOIN "db_oks_zu"."tbl_inventory" ON
"db_oks_zu"."tbl_inventory"."register_id"="db_oks_zu"."tbl_register"."register_id"

Left JOIN "db_oks_zu"."tbl_location" ON
"db_oks_zu"."tbl_location"."parameter_id"="reestr_base"."invFiles"."id"
Left JOIN "db_class"."kladrCache" ON
"db_class"."kladrCache"."code"="db_oks_zu"."tbl_location"."kladr_id"
Left JOIN "db_oks_zu"."tbl_position" ON
"db_oks_zu"."tbl_position"."object_id"="db_oks_zu"."tbl_objects_main"."object_id"

WHERE (reestr_base."invFiles"."placeStore" = '1') AND
(db_oks_zu."tbl_inventory"."organization_id" = '1');

When reestr_base."invFiles"."placeStore" and
db_oks_zu."tbl_inventory"."organization_id" in where clause compared with
'1' or '2' i'm get following query plan (and real execution time is about 10
seconds for 10,000 rows):

QUERY PLAN
Hash Left Join  (cost=76024.15..169664.40 rows=76919 width=429)
"  Hash Cond: ((tbl_location.kladr_id)::text = (""kladrCache"".code)::text)"
  ->  Hash Left Join  (cost=75094.18..165849.97 rows=76919 width=430)
"        Hash Cond: (""invFiles"".id = tbl_location.parameter_id)"
        ->  Hash Left Join  (cost=25195.02..42082.87 rows=886 width=106)
              Hash Cond: (tbl_objects_main.object_id =
tbl_position.object_id)
              ->  Nested Loop  (cost=21660.73..38535.64 rows=886 width=117)
                    ->  Nested Loop  (cost=21660.73..37302.47 rows=886
width=129)
                          ->  Nested Loop  (cost=21660.73..36846.12 rows=894
width=86)
                                ->  Hash Join  (cost=21660.73..36458.09
rows=908 width=86)
"                                      Hash Cond: (tbl_rights.object_id =
""fileObjects"".""objectId"")"
                                      ->  Seq Scan on tbl_rights
(cost=0.00..12990.66 rows=479366 width=35)
                                      ->  Hash  (cost=21654.66..21654.66
rows=486 width=51)
                                            ->  Hash Join
(cost=18174.09..21654.66 rows=486 width=51)
                                                  Hash Cond:
(tbl_inventory.register_id = tbl_register.register_id)
                                                  ->  Bitmap Heap Scan on
tbl_inventory  (cost=593.88..4016.58 rows=14136 width=16)
                                                        Recheck Cond:
((organization_id)::text = '1'::text)
                                                        ->  Bitmap Index
Scan on tbl_inventory_idx1  (cost=0.00..590.35 rows=14136 width=0)
                                                              Index Cond:
((organization_id)::text = '1'::text)
                                                  ->  Hash
(cost=17387.93..17387.93 rows=15382 width=67)
                                                        ->  Hash Join
(cost=1358.24..17387.93 rows=15382 width=67)
"                                                              Hash Cond:
(tbl_register.object_id = ""fileObjects"".""objectId"")"
                                                              ->  Seq Scan
on tbl_register  (cost=0.00..12520.21 rows=447421 width=35)
                                                              ->  Hash
(cost=1165.97..1165.97 rows=15382 width=32)
                                                                    ->  Hash
Join  (cost=242.29..1165.97 rows=15382 width=32)
"
Hash Cond: (""fileObjects"".""fileId"" = ""invFiles"".id)"
"
->  Seq Scan on ""fileObjects""  (cost=0.00..610.30 rows=25530 width=32)"

->  Hash  (cost=201.95..201.95 rows=3227 width=16)
"
->  Seq Scan on ""invFiles""  (cost=0.00..201.95 rows=3227 width=16)"
"
Filter: ((""placeStore"")::text = '1'::text)"
                                ->  Index Scan using lnk_owners_right_id_key
on lnk_owners  (cost=0.00..0.41 rows=1 width=32)
                                      Index Cond: (lnk_owners.right_id =
tbl_rights.right_id)
                          ->  Index Scan using powners_pkey on tbl_powners
(cost=0.00..0.50 rows=1 width=75)
                                Index Cond: (tbl_powners.powners_id =
lnk_owners.powners_id)
                    ->  Index Scan using objects_main_pkey1 on
tbl_objects_main  (cost=0.00..1.38 rows=1 width=36)
                          Index Cond: (tbl_objects_main.object_id =
tbl_rights.object_id)
              ->  Hash  (cost=2157.46..2157.46 rows=110146 width=21)
                    ->  Seq Scan on tbl_position  (cost=0.00..2157.46
rows=110146 width=21)
        ->  Hash  (cost=22516.85..22516.85 rows=464985 width=356)
              ->  Seq Scan on tbl_location  (cost=0.00..22516.85 rows=464985
width=356)
  ->  Hash  (cost=727.21..727.21 rows=16221 width=104)
"        ->  Seq Scan on ""kladrCache""  (cost=0.00..727.21 rows=16221
width=104)"

But if reestr_base."invFiles"."placeStore" and
db_oks_zu."tbl_inventory"."organization_id" compared with '3','4'... query
plan changed to the folowing (and real execution time is 70 seconds for 200
rows)

QUERY PLAN
Nested Loop Left Join  (cost=2397.45..45626.60 rows=87 width=429)
  ->  Nested Loop Left Join  (cost=2397.45..45599.74 rows=87 width=430)
"        Join Filter: (tbl_location.parameter_id = ""invFiles"".id)"
        ->  Nested Loop Left Join  (cost=2397.45..17270.57 rows=1 width=106)
              ->  Nested Loop  (cost=2397.45..17262.28 rows=1 width=117)
                    ->  Nested Loop  (cost=2397.45..17260.88 rows=1
width=129)
                          ->  Nested Loop  (cost=2397.45..17260.37 rows=1
width=86)
                                ->  Nested Loop  (cost=2397.45..17259.95
rows=1 width=86)
                                      ->  Nested Loop
(cost=2397.45..17253.13 rows=22 width=86)
                                            ->  Hash Join
(cost=2397.45..17187.99 rows=225 width=54)
                                                  Hash Cond:
(tbl_rights.object_id = tbl_register.object_id)
                                                  ->  Seq Scan on
tbl_rights  (cost=0.00..12990.66 rows=479366 width=35)
                                                  ->  Hash
(cost=2394.83..2394.83 rows=210 width=19)
                                                        ->  Nested Loop
(cost=9.95..2394.83 rows=210 width=19)
                                                              ->  Bitmap
Heap Scan on tbl_inventory  (cost=9.95..675.15 rows=210 width=16)
                                                                    Recheck
Cond: ((organization_id)::text = '12'::text)
                                                                    ->
Bitmap Index Scan on tbl_inventory_idx1  (cost=0.00..9.90 rows=210 width=0)

Index Cond: ((organization_id)::text = '12'::text)
                                                              ->  Index Scan
using register_pkey on tbl_register  (cost=0.00..8.18 rows=1 width=35)
                                                                    Index
Cond: (tbl_register.register_id = tbl_inventory.register_id)
"                                            ->  Index Scan using
table3_pkey on ""fileObjects""  (cost=0.00..0.28 rows=1 width=32)"
"                                                  Index Cond:
(""fileObjects"".""objectId"" = tbl_rights.object_id)"
"                                      ->  Index Scan using
""invFiles_new_pkey"" on ""invFiles""  (cost=0.00..0.30 rows=1 width=16)"
"                                            Index Cond: (""invFiles"".id =
""fileObjects"".""fileId"")"
"                                            Filter:
((""invFiles"".""placeStore"")::text = '12'::text)"
                                ->  Index Scan using lnk_owners_right_id_key
on lnk_owners  (cost=0.00..0.41 rows=1 width=32)
                                      Index Cond: (lnk_owners.right_id =
tbl_rights.right_id)
                          ->  Index Scan using powners_pkey on tbl_powners
(cost=0.00..0.50 rows=1 width=75)
                                Index Cond: (tbl_powners.powners_id =
lnk_owners.powners_id)
                    ->  Index Scan using objects_main_pkey1 on
tbl_objects_main  (cost=0.00..1.38 rows=1 width=36)
                          Index Cond: (tbl_objects_main.object_id =
tbl_rights.object_id)
              ->  Index Scan using tbl_position_idx on tbl_position
(cost=0.00..8.28 rows=1 width=21)
                    Index Cond: (tbl_position.object_id =
tbl_objects_main.object_id)
        ->  Seq Scan on tbl_location  (cost=0.00..22516.85 rows=464985
width=356)
"  ->  Index Scan using ""kladrCache_pkey"" on ""kladrCache""
(cost=0.00..0.28 rows=1 width=104)"
"        Index Cond: ((""kladrCache"".code)::text =
(tbl_location.kladr_id)::text)"


What caused changing plan? Can i force to use one (first in expamples) plan
for any values in where clause?

Thanks
-- 
------
Regards,
Tatarnikov Alexander

[Attachment #3 (text/html)]

Hello!<br><br>I have following query:<br>SELECT \
<br>db_oks_zu.&quot;tbl_location&quot;.&quot;full_address&quot;,<br>db_class.&quot;kla \
drCache&quot;.&quot;region&quot;,<br>db_class.&quot;kladrCache&quot;.&quot;mo&quot;,<br>


db_class.&quot;kladrCache&quot;.&quot;city&quot;,<br>db_class.&quot;kladrCache&quot;.& \
quot;street&quot;,<br>db_oks_zu.&quot;tbl_location&quot;.&quot;house&quot;,<br>db_oks_zu.&quot;tbl_position&quot;.&quot;number_flat&quot;,<br>


((((((COALESCE(db_oks_zu.&quot;tbl_powners&quot;.&quot;psurname&quot;,&#39;&#39;))||(&#39; \
&#39;))||(COALESCE(db_oks_zu.&quot;tbl_powners&quot;.&quot;pname&quot;,&#39;&#39;)))||(&#39; \
&#39;))||(COALESCE(db_oks_zu.&quot;tbl_powners&quot;.&quot;ppatronimic&quot;,&#39;&#39;)))||(&#39; \
&#39;))||(COALESCE(db_oks_zu.&quot;tbl_powners&quot;.&quot;pnumdoc&quot;,&#39;&#39;)) \
as c8,<br>

db_oks_zu.&quot;tbl_register&quot;.&quot;invent_number&quot;,<br>db_oks_zu.&quot;tbl_r \
ights&quot;.&quot;share&quot;,<br>db_oks_zu.&quot;tbl_objects_main&quot;.&quot;date_modifed&quot;,<br>db_oks_zu.&quot;tbl_objects_main&quot;.&quot;parent_id&quot; \
FROM <br>

&quot;db_oks_zu&quot;.&quot;tbl_powners&quot; <br>Left JOIN \
&quot;db_oks_zu&quot;.&quot;lnk_owners&quot; ON \
&quot;db_oks_zu&quot;.&quot;lnk_owners&quot;.&quot;powners_id&quot;=&quot;db_oks_zu&quot;.&quot;tbl_powners&quot;.&quot;powners_id&quot; \
<br>

Left JOIN &quot;db_oks_zu&quot;.&quot;tbl_rights&quot; ON \
&quot;db_oks_zu&quot;.&quot;tbl_rights&quot;.&quot;right_id&quot;=&quot;db_oks_zu&quot;.&quot;lnk_owners&quot;.&quot;right_id&quot; \
<br>Left JOIN &quot;db_oks_zu&quot;.&quot;tbl_objects_main&quot; ON \
&quot;db_oks_zu&quot;.&quot;tbl_objects_main&quot;.&quot;object_id&quot;=&quot;db_oks_zu&quot;.&quot;tbl_rights&quot;.&quot;object_id&quot; \
<br>

Left JOIN &quot;reestr_base&quot;.&quot;fileObjects&quot; ON \
&quot;reestr_base&quot;.&quot;fileObjects&quot;.&quot;objectId&quot;=&quot;db_oks_zu&quot;.&quot;tbl_objects_main&quot;.&quot;object_id&quot; \
<br>Left JOIN &quot;reestr_base&quot;.&quot;invFiles&quot; ON \
&quot;reestr_base&quot;.&quot;invFiles&quot;.&quot;id&quot;=&quot;reestr_base&quot;.&quot;fileObjects&quot;.&quot;fileId&quot; \
<br>

Left JOIN &quot;db_oks_zu&quot;.&quot;tbl_register&quot; ON \
&quot;db_oks_zu&quot;.&quot;tbl_register&quot;.&quot;object_id&quot;=&quot;db_oks_zu&quot;.&quot;tbl_objects_main&quot;.&quot;object_id&quot; \
<br>Left JOIN &quot;db_oks_zu&quot;.&quot;tbl_inventory&quot; ON \
&quot;db_oks_zu&quot;.&quot;tbl_inventory&quot;.&quot;register_id&quot;=&quot;db_oks_zu&quot;.&quot;tbl_register&quot;.&quot;register_id&quot; \
<br>

Left JOIN &quot;db_oks_zu&quot;.&quot;tbl_location&quot; ON \
&quot;db_oks_zu&quot;.&quot;tbl_location&quot;.&quot;parameter_id&quot;=&quot;reestr_base&quot;.&quot;invFiles&quot;.&quot;id&quot; \
<br>Left JOIN &quot;db_class&quot;.&quot;kladrCache&quot; ON \
&quot;db_class&quot;.&quot;kladrCache&quot;.&quot;code&quot;=&quot;db_oks_zu&quot;.&quot;tbl_location&quot;.&quot;kladr_id&quot; \
<br>

Left JOIN &quot;db_oks_zu&quot;.&quot;tbl_position&quot; ON \
&quot;db_oks_zu&quot;.&quot;tbl_position&quot;.&quot;object_id&quot;=&quot;db_oks_zu&quot;.&quot;tbl_objects_main&quot;.&quot;object_id&quot; \
<br>WHERE (reestr_base.&quot;invFiles&quot;.&quot;placeStore&quot; = &#39;1&#39;) AND \
(db_oks_zu.&quot;tbl_inventory&quot;.&quot;organization_id&quot; = &#39;1&#39;);<br>

<br>When reestr_base.&quot;invFiles&quot;.&quot;placeStore&quot; and \
db_oks_zu.&quot;tbl_inventory&quot;.&quot;organization_id&quot; in where clause \
compared with &#39;1&#39; or &#39;2&#39; i&#39;m get following query plan (and real \
execution time is about 10 seconds for 10,000 rows):<br> <br>QUERY PLAN<br>Hash Left \
Join  (cost=76024.15..169664.40 rows=76919 width=429)<br>&quot;  Hash Cond: \
((tbl_location.kladr_id)::text = \
(&quot;&quot;kladrCache&quot;&quot;.code)::text)&quot;<br>  -&gt;  Hash Left Join  \
(cost=75094.18..165849.97 rows=76919 width=430)<br> &quot;        Hash Cond: \
(&quot;&quot;invFiles&quot;&quot;.id = tbl_location.parameter_id)&quot;<br>        \
-&gt;  Hash Left Join  (cost=25195.02..42082.87 rows=886 width=106)<br>              \
                Hash Cond: (tbl_objects_main.object_id = tbl_position.object_id)<br>
              -&gt;  Nested Loop  (cost=21660.73..38535.64 rows=886 width=117)<br>    \
-&gt;  Nested Loop  (cost=21660.73..37302.47 rows=886 width=129)<br>                  \
                -&gt;  Nested Loop  (cost=21660.73..36846.12 rows=894 width=86)<br>
                                -&gt;  Hash Join  (cost=21660.73..36458.09 rows=908 \
width=86)<br>&quot;                                      Hash Cond: \
(tbl_rights.object_id = \
                &quot;&quot;fileObjects&quot;&quot;.&quot;&quot;objectId&quot;&quot;)&quot;<br>
                
                                      -&gt;  Seq Scan on tbl_rights  \
(cost=0.00..12990.66 rows=479366 width=35)<br>                                      \
-&gt;  Hash  (cost=21654.66..21654.66 rows=486 width=51)<br>                          \
-&gt;  Hash Join  (cost=18174.09..21654.66 rows=486 width=51)<br>  Hash Cond: \
(tbl_inventory.register_id = tbl_register.register_id)<br>                            \
-&gt;  Bitmap Heap Scan on tbl_inventory  (cost=593.88..4016.58 rows=14136 \
width=16)<br>  Recheck Cond: ((organization_id)::text = &#39;1&#39;::text)<br>        \
-&gt;  Bitmap Index Scan on tbl_inventory_idx1  (cost=0.00..590.35 rows=14136 \
width=0)<br>  Index Cond: ((organization_id)::text = &#39;1&#39;::text)<br>           \
                -&gt;  Hash  (cost=17387.93..17387.93 rows=15382 width=67)<br>
                                                        -&gt;  Hash Join  \
(cost=1358.24..17387.93 rows=15382 width=67)<br>&quot;                                \
Hash Cond: (tbl_register.object_id = \
                &quot;&quot;fileObjects&quot;&quot;.&quot;&quot;objectId&quot;&quot;)&quot;<br>
                
                                                              -&gt;  Seq Scan on \
tbl_register  (cost=0.00..12520.21 rows=447421 width=35)<br>                          \
                -&gt;  Hash  (cost=1165.97..1165.97 rows=15382 width=32)<br>
                                                                    -&gt;  Hash Join  \
(cost=242.29..1165.97 rows=15382 width=32)<br>&quot;                                  \
Hash Cond: (&quot;&quot;fileObjects&quot;&quot;.&quot;&quot;fileId&quot;&quot; = \
&quot;&quot;invFiles&quot;&quot;.id)&quot;<br> &quot;                                 \
-&gt;  Seq Scan on &quot;&quot;fileObjects&quot;&quot;  (cost=0.00..610.30 rows=25530 \
width=32)&quot;<br>                                                                   \
-&gt;  Hash  (cost=201.95..201.95 rows=3227 width=16)<br> &quot;                      \
-&gt;  Seq Scan on &quot;&quot;invFiles&quot;&quot;  (cost=0.00..201.95 rows=3227 \
width=16)&quot;<br>&quot;                                                             \
                Filter: ((&quot;&quot;placeStore&quot;&quot;)::text = \
                &#39;1&#39;::text)&quot;<br>
                                -&gt;  Index Scan using lnk_owners_right_id_key on \
lnk_owners  (cost=0.00..0.41 rows=1 width=32)<br>                                     \
                Index Cond: (lnk_owners.right_id = tbl_rights.right_id)<br>
                          -&gt;  Index Scan using powners_pkey on tbl_powners  \
(cost=0.00..0.50 rows=1 width=75)<br>                                Index Cond: \
(tbl_powners.powners_id = lnk_owners.powners_id)<br>                    -&gt;  Index \
Scan using objects_main_pkey1 on tbl_objects_main  (cost=0.00..1.38 rows=1 \
width=36)<br>  Index Cond: (tbl_objects_main.object_id = tbl_rights.object_id)<br>    \
-&gt;  Hash  (cost=2157.46..2157.46 rows=110146 width=21)<br>                    \
                -&gt;  Seq Scan on tbl_position  (cost=0.00..2157.46 rows=110146 \
                width=21)<br>
        -&gt;  Hash  (cost=22516.85..22516.85 rows=464985 width=356)<br>              \
-&gt;  Seq Scan on tbl_location  (cost=0.00..22516.85 rows=464985 width=356)<br>  \
-&gt;  Hash  (cost=727.21..727.21 rows=16221 width=104)<br> &quot;        -&gt;  Seq \
Scan on &quot;&quot;kladrCache&quot;&quot;  (cost=0.00..727.21 rows=16221 \
width=104)&quot;<br><br>But if \
reestr_base.&quot;invFiles&quot;.&quot;placeStore&quot; and \
db_oks_zu.&quot;tbl_inventory&quot;.&quot;organization_id&quot; compared with \
&#39;3&#39;,&#39;4&#39;... query plan changed to the folowing (and real execution \
time is 70 seconds for 200 rows)<br> <br clear="all">QUERY PLAN<br>Nested Loop Left \
Join  (cost=2397.45..45626.60 rows=87 width=429)<br>  -&gt;  Nested Loop Left Join  \
(cost=2397.45..45599.74 rows=87 width=430)<br>&quot;        Join Filter: \
                (tbl_location.parameter_id = \
                &quot;&quot;invFiles&quot;&quot;.id)&quot;<br>
        -&gt;  Nested Loop Left Join  (cost=2397.45..17270.57 rows=1 width=106)<br>   \
-&gt;  Nested Loop  (cost=2397.45..17262.28 rows=1 width=117)<br>                    \
                -&gt;  Nested Loop  (cost=2397.45..17260.88 rows=1 width=129)<br>
                          -&gt;  Nested Loop  (cost=2397.45..17260.37 rows=1 \
width=86)<br>                                -&gt;  Nested Loop  \
(cost=2397.45..17259.95 rows=1 width=86)<br>                                      \
                -&gt;  Nested Loop  (cost=2397.45..17253.13 rows=22 width=86)<br>
                                            -&gt;  Hash Join  (cost=2397.45..17187.99 \
rows=225 width=54)<br>                                                  Hash Cond: \
(tbl_rights.object_id = tbl_register.object_id)<br>                                   \
                -&gt;  Seq Scan on tbl_rights  (cost=0.00..12990.66 rows=479366 \
                width=35)<br>
                                                  -&gt;  Hash  (cost=2394.83..2394.83 \
rows=210 width=19)<br>                                                        -&gt;  \
                Nested Loop  (cost=9.95..2394.83 rows=210 width=19)<br>
                                                              -&gt;  Bitmap Heap Scan \
on tbl_inventory  (cost=9.95..675.15 rows=210 width=16)<br>                           \
                Recheck Cond: ((organization_id)::text = &#39;12&#39;::text)<br>
                                                                    -&gt;  Bitmap \
Index Scan on tbl_inventory_idx1  (cost=0.00..9.90 rows=210 width=0)<br>              \
                Index Cond: ((organization_id)::text = &#39;12&#39;::text)<br>
                                                              -&gt;  Index Scan using \
register_pkey on tbl_register  (cost=0.00..8.18 rows=1 width=35)<br>                  \
Index Cond: (tbl_register.register_id = tbl_inventory.register_id)<br> &quot;         \
-&gt;  Index Scan using table3_pkey on &quot;&quot;fileObjects&quot;&quot;  \
(cost=0.00..0.28 rows=1 width=32)&quot;<br>&quot;                                     \
Index Cond: (&quot;&quot;fileObjects&quot;&quot;.&quot;&quot;objectId&quot;&quot; = \
tbl_rights.object_id)&quot;<br> &quot;                                      -&gt;  \
Index Scan using &quot;&quot;invFiles_new_pkey&quot;&quot; on \
&quot;&quot;invFiles&quot;&quot;  (cost=0.00..0.30 rows=1 width=16)&quot;<br>&quot;   \
Index Cond: (&quot;&quot;invFiles&quot;&quot;.id = \
&quot;&quot;fileObjects&quot;&quot;.&quot;&quot;fileId&quot;&quot;)&quot;<br> &quot;  \
Filter: ((&quot;&quot;invFiles&quot;&quot;.&quot;&quot;placeStore&quot;&quot;)::text \
= &#39;12&#39;::text)&quot;<br>                                -&gt;  Index Scan \
using lnk_owners_right_id_key on lnk_owners  (cost=0.00..0.41 rows=1 width=32)<br>  \
Index Cond: (lnk_owners.right_id = tbl_rights.right_id)<br>                          \
-&gt;  Index Scan using powners_pkey on tbl_powners  (cost=0.00..0.50 rows=1 \
width=75)<br>                                Index Cond: (tbl_powners.powners_id = \
                lnk_owners.powners_id)<br>
                    -&gt;  Index Scan using objects_main_pkey1 on tbl_objects_main  \
(cost=0.00..1.38 rows=1 width=36)<br>                          Index Cond: \
(tbl_objects_main.object_id = tbl_rights.object_id)<br>              -&gt;  Index \
Scan using tbl_position_idx on tbl_position  (cost=0.00..8.28 rows=1 width=21)<br>  \
Index Cond: (tbl_position.object_id = tbl_objects_main.object_id)<br>        -&gt;  \
Seq Scan on tbl_location  (cost=0.00..22516.85 rows=464985 width=356)<br>&quot;  \
-&gt;  Index Scan using &quot;&quot;kladrCache_pkey&quot;&quot; on \
&quot;&quot;kladrCache&quot;&quot;  (cost=0.00..0.28 rows=1 width=104)&quot;<br> \
&quot;        Index Cond: ((&quot;&quot;kladrCache&quot;&quot;.code)::text = \
(tbl_location.kladr_id)::text)&quot;<br><br><br>What caused changing plan? Can i \
force to use one (first in expamples) plan for any values in where clause?<br> \
<br>Thanks<br>-- <br>------<br>Regards,<br>Tatarnikov Alexander<br>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic