Re: Disabling nested loops - worst case performance

From: Anssi Kääriäinen <anssi(dot)kaariainen(at)thl(dot)fi>
To: Vitalii Tymchyshyn <tivv00(at)gmail(dot)com>
Cc: "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Disabling nested loops - worst case performance
Date: 2011-03-18 11:59:29
Message-ID: 4D834921.6060705@thl.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On 03/18/2011 12:52 PM, Vitalii Tymchyshyn wrote:
> If your queries work on single attribute, you can try adding partial
> indexes for different attributes. Note that in this case parameterized
> statements may prevent index usage, so check also with attribute id inlined.
>
> Best regards, Vitalii Tymchyshyn

Unfortunately this does not help for the statistics, and (I guess)
nested loops will still be used when joining:

hot2=> explain analyze select * from attr_value where attr_tunniste =
'suhde_hyvaksytty' and arvo_text = 't';
QUERY
PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------
Index Scan using attr_value_arvo_text_idx1 on attr_value
(cost=0.00..343.59 rows=152 width=118) (actual time=0.076..7.768
rows=3096 loops=1)
Index Cond: (arvo_text = 't'::text)
Filter: ((attr_tunniste)::text = 'suhde_hyvaksytty'::text)
Total runtime: 10.855 ms
(4 rows)

hot2=> create index suhde_hyvaksytty_idx on attr_value(arvo_text) where
attr_tunniste = 'suhde_hyvaksytty';
CREATE INDEX
hot2=> analyze attr_value;
hot2=> explain analyze select * from attr_value where attr_tunniste =
'suhde_hyvaksytty' and arvo_text = 't';
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------
Index Scan using suhde_hyvaksytty_idx on attr_value (cost=0.00..43.72
rows=152 width=118) (actual time=0.093..4.776 rows=3096 loops=1)
Index Cond: (arvo_text = 't'::text)
Total runtime: 7.817 ms
(3 rows)

- Anssi

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Jeff 2011-03-18 12:14:57 Re: Xeon twice the performance of opteron
Previous Message Thomas Kellerer 2011-03-18 11:14:05 Re: Disabling nested loops - worst case performance