[PERFORM] Disabling nested loops - worst case performance

2011-03-18 Thread Anssi Kääriäinen
Hello list, I am working on a Entity-Attribute-Value (EAV) database using PostgreSQL 8.4.7. The basic problem is that when joining multiple times different entities the planner thinks that there is vastly less rows to join than there is in reality and decides to use multiple nested loops for

Re: [PERFORM] Disabling nested loops - worst case performance

2011-03-18 Thread Pavel Stehule
Hello for example queries with LIMIT clause can be significantly faster with nested loop. But you don't need to disable nested loop globally. You can wrap your query to sql functions and disable nested loop just for these functions. Regards Pavel Stehule 2011/3/18 Anssi Kääriäinen

Re: [PERFORM] Disabling nested loops - worst case performance

2011-03-18 Thread Anssi Kääriäinen
On 03/18/2011 09:02 AM, Pavel Stehule wrote: for example queries with LIMIT clause can be significantly faster with nested loop. But you don't need to disable nested loop globally. You can wrap your query to sql functions and disable nested loop just for these functions. Thank you for your

Re: [PERFORM] Disabling nested loops - worst case performance

2011-03-18 Thread Vitalii Tymchyshyn
18.03.11 09:15, Anssi Kääriäinen написав(ла): Hello list, I am working on a Entity-Attribute-Value (EAV) database using PostgreSQL 8.4.7. The basic problem is that when joining multiple times different entities the planner thinks that there is vastly less rows to join than there is in

Re: [PERFORM] Disabling nested loops - worst case performance

2011-03-18 Thread Thomas Kellerer
Anssi Kääriäinen, 18.03.2011 08:15: Hello list, I am working on a Entity-Attribute-Value (EAV) database using PostgreSQL 8.4.7. The basic problem is that when joining multiple times different entities the planner thinks that there is vastly less rows to join than there is in reality and decides

Re: [PERFORM] Disabling nested loops - worst case performance

2011-03-18 Thread Anssi Kääriäinen
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

Re: [PERFORM] Disabling nested loops - worst case performance

2011-03-18 Thread Anssi Kääriäinen
On 03/18/2011 01:14 PM, Thomas Kellerer wrote: Did you consider using hstore instead? I think in the PostgreSQL world, this is a better alternative than EAV and most probably faster as well. No, we did not. The reason is that we want to track each attribute with bi-temporal timestamps. The

Re: [PERFORM] Disabling nested loops - worst case performance

2011-03-18 Thread Claudio Freire
On Fri, Mar 18, 2011 at 7:52 AM, Vitalii Tymchyshyn tiv...@gmail.com wrote: 18.03.11 09:15, Anssi Kääriäinen написав(ла): Hello. 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