Re: [PERFORM] Bad plan for nested loop + limit

2009-03-30 Thread Alexander Staubo
On Sun, Mar 1, 2009 at 4:32 AM, Robert Haas robertmh...@gmail.com wrote: What do you have default_statistics_target set to?  If it's less than 100, you should probably raise it to 100 and re-analyze (the default value for 8.4 will be 100, but for 8.3 and prior it is 10). Changing it to 100

Re: [PERFORM] Bad plan for nested loop + limit

2009-02-28 Thread Alexander Staubo
On Fri, Feb 27, 2009 at 11:54 PM, Robert Haas robertmh...@gmail.com wrote: The problem here is that the planner estimates the cost of a Limit plan node by adding up (1) the startup cost of the underlying plan node, in this case 0 for the nestjoin, and (2) a percentage of the run cost, based on

Re: [PERFORM] Bad plan for nested loop + limit

2009-02-28 Thread Robert Haas
On Sat, Feb 28, 2009 at 11:20 AM, Alexander Staubo a...@bengler.no wrote: On Fri, Feb 27, 2009 at 11:54 PM, Robert Haas robertmh...@gmail.com wrote: The problem here is that the planner estimates the cost of a Limit plan node by adding up (1) the startup cost of the underlying plan node, in

Re: [PERFORM] Bad plan for nested loop + limit

2009-02-27 Thread Alexander Staubo
On Sun, Feb 15, 2009 at 5:45 PM, Alexander Staubo a...@bengler.no wrote: On Sun, Feb 15, 2009 at 5:29 AM, David Wilson david.t.wil...@gmail.com wrote: On Sat, Feb 14, 2009 at 5:25 PM, Alexander Staubo a...@bengler.no wrote: Output from explain analyze:  Limit  (cost=0.00..973.63 rows=4

Re: [PERFORM] Bad plan for nested loop + limit

2009-02-27 Thread Robert Haas
On Fri, Feb 27, 2009 at 3:18 PM, Alexander Staubo a...@bengler.no wrote: On Sun, Feb 15, 2009 at 5:45 PM, Alexander Staubo a...@bengler.no wrote: On Sun, Feb 15, 2009 at 5:29 AM, David Wilson david.t.wil...@gmail.com wrote: On Sat, Feb 14, 2009 at 5:25 PM, Alexander Staubo a...@bengler.no

Re: [PERFORM] Bad plan for nested loop + limit

2009-02-15 Thread Alexander Staubo
On Sun, Feb 15, 2009 at 5:29 AM, David Wilson david.t.wil...@gmail.com wrote: On Sat, Feb 14, 2009 at 5:25 PM, Alexander Staubo a...@bengler.no wrote: Output from explain analyze: Limit (cost=0.00..973.63 rows=4 width=48) (actual time=61.554..4039.704 rows=1 loops=1) - Nested Loop

[PERFORM] Bad plan for nested loop + limit

2009-02-14 Thread Alexander Staubo
This dinky little query takes about 4 seconds to run: select event_occurrences.* from event_occurrences join section_items on section_items.subject_id = event_occurrences.event_id and section_items.subject_type = 'Event' and section_items.sandbox_id = 16399 where

Re: [PERFORM] Bad plan for nested loop + limit

2009-02-14 Thread David Wilson
On Sat, Feb 14, 2009 at 5:25 PM, Alexander Staubo a...@bengler.no wrote: Output from explain analyze: Limit (cost=0.00..973.63 rows=4 width=48) (actual time=61.554..4039.704 rows=1 loops=1) - Nested Loop (cost=0.00..70101.65 rows=288 width=48) (actual time=61.552..4039.700 rows=1