Re: [SQL] How to influence the planner

2007-09-04 Thread Richard Ray
Thanks guys Lesson learned On Tue, 4 Sep 2007, Scott Marlowe wrote: On 8/31/07, Richard Ray <[EMAIL PROTECTED]> wrote: Changing to enable_seqscan = on does solve this problem, thanks Is there some method of crafting a query that will assert my wishes to the planner When is enable_seqscan = o

Re: [SQL] How to influence the planner

2007-09-04 Thread Scott Marlowe
On 8/31/07, Richard Ray <[EMAIL PROTECTED]> wrote: > Changing to enable_seqscan = on does solve this problem, thanks > Is there some method of crafting a query that will assert my wishes to the > planner > When is enable_seqscan = off appropriate enable_xxx = off are troubleshooting tools. They

Re: [SQL] How to influence the planner

2007-09-01 Thread Richard Huxton
Richard Ray wrote: When is enable_seqscan = off appropriate Never(*) It's not for normal usage, the various enable_xxx settings do let you experiment with different options if you think the planner is making a mistake. (*) OK, sooner or later, if you have enough systems and enough perfor

Re: [SQL] How to influence the planner

2007-08-31 Thread Richard Ray
On Fri, 31 Aug 2007, Tom Lane wrote: Richard Ray <[EMAIL PROTECTED]> writes: On Fri, 31 Aug 2007, Michael Glaesemann wrote: EXPLAIN ANALYZE will help you see what the planner is doing to produce the results. mda=# EXPLAIN ANALYZE select * from t1 where length(bar) = 0 order by foo;

Re: [SQL] How to influence the planner

2007-08-31 Thread Tom Lane
Michael Glaesemann <[EMAIL PROTECTED]> writes: > On Aug 31, 2007, at 16:07 , Richard Ray wrote: >>> If length(bar) = 0 is a common operation on this table, you might >>> consider using an expression index on t1: >> >>> create index t1_length_bar_idx on t1 (length(bar)); >> >> This is a one time

Re: [SQL] How to influence the planner

2007-08-31 Thread Tom Lane
Richard Ray <[EMAIL PROTECTED]> writes: > On Fri, 31 Aug 2007, Michael Glaesemann wrote: >> EXPLAIN ANALYZE will help you see what the planner is doing to produce the >> results. > mda=# EXPLAIN ANALYZE select * from t1 where length(bar) = 0 order by foo; >

Re: [SQL] How to influence the planner

2007-08-31 Thread Michael Glaesemann
On Aug 31, 2007, at 16:07 , Richard Ray wrote: Total runtime: 2349614.258 ms (3 rows) Wow. Nearly 40 minutes! What are your work_mem set at? You may want to increase work_mem, as it might help with the sort. The index for foo on t1 is the primary index t1_pkey Why is it slower using the

Re: [SQL] How to influence the planner

2007-08-31 Thread Richard Ray
On Fri, 31 Aug 2007, Michael Glaesemann wrote: On Aug 31, 2007, at 13:32 , Richard Ray wrote: "select * from t1 where length(bar) = 0;" runs about 2 minutes "select * from t1 where length(bar) = 0 order by foo ;" ran until I stopped it after about 20 minutes EXPLAIN ANALYZE will help you s

Re: [SQL] How to influence the planner

2007-08-31 Thread Michael Glaesemann
On Aug 31, 2007, at 13:32 , Richard Ray wrote: "select * from t1 where length(bar) = 0;" runs about 2 minutes "select * from t1 where length(bar) = 0 order by foo ;" ran until I stopped it after about 20 minutes EXPLAIN ANALYZE will help you see what the planner is doing to produce the res

[SQL] How to influence the planner

2007-08-31 Thread Richard Ray
I have a table, t1, with about 12 million rows The column foo is unique and indexed The column bar is not unique and is indexed "select * from t1 where length(bar) = 0;" runs about 2 minutes "select * from t1 where length(bar) = 0 order by foo ;" ran until I stopped it after about 20 minutes My s