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

Re: [SQL] Incomprehensible dogged sort in Merge Join

2007-08-31 Thread Chris Browne
[EMAIL PROTECTED] (Gregory Stark) writes: > "Aleksandr Vinokurov" <[EMAIL PROTECTED]> writes: > >> Gregory Stark wrote: >>> >>> What version are you running with? >> >> 8.0.1, sorry for missing. > > There have been 12 bug-fix releases since then on the 8.0 branch including > updating timezones to r

Re: [SQL] Reporting functions (OLAP)

2007-08-31 Thread Chris Browne
[EMAIL PROTECTED] (Sean Davis) writes: > I am looking for reporting extensions such as windowing, ranking, > leads/lags, etc. for postgresql. A quick google search turned up > some "working on it" type results, but I was wondering if anything > actually existed up to this point? No, nothing exist

Re: [SQL] Incomprehensible dogged sort in Merge Join

2007-08-31 Thread Gregory Stark
"Aleksandr Vinokurov" <[EMAIL PROTECTED]> writes: > Gregory Stark wrote: >> >> What version are you running with? > > 8.0.1, sorry for missing. There have been 12 bug-fix releases since then on the 8.0 branch including updating timezones to reflect the new daylight saving time rules for North Am

Re: [SQL] Incomprehensible dogged sort in Merge Join

2007-08-31 Thread Aleksandr Vinokurov
Alvaro Herrera wrote: Aleksandr Vinokurov escribió: Tom Lane wrote: When criticizing planner deficiencies, it's considered polite to use something that's less than two major releases back ;-) Sorry, it was blown out from my head at the end of composing: my version is 8.0.1, not so old, IMHO.

Re: [SQL] Incomprehensible dogged sort in Merge Join

2007-08-31 Thread Alvaro Herrera
Aleksandr Vinokurov escribió: > Tom Lane wrote: >> When criticizing planner deficiencies, it's considered polite to use >> something that's less than two major releases back ;-) > > Sorry, it was blown out from my head at the end of composing: my version is > 8.0.1, not so old, IMHO. It _is_ qui

Re: [SQL] Incomprehensible dogged sort in Merge Join

2007-08-31 Thread Aleksandr Vinokurov
Gregory Stark wrote: "Aleksandr Vinokurov" <[EMAIL PROTECTED]> writes: And that is its plan (attached one is the same, but with costs): -< Merge Left Join Merge Cond: ("outer".name = "inner".name) -> Sort Sort K

Re: [SQL] Incomprehensible dogged sort in Merge Join

2007-08-31 Thread Aleksandr Vinokurov
Tom Lane wrote: Aleksandr Vinokurov <[EMAIL PROTECTED]> writes: Trying to get an extra time savings in my query, I stopped at an unusual doggedness of the planner. Merge Left Join Merge Cond: ("outer".name = "inner".name) -> Sort Sort Key: log.name -> Seq Scan

Re: [SQL] Incomprehensible dogged sort in Merge Join

2007-08-31 Thread Gregory Stark
"Aleksandr Vinokurov" <[EMAIL PROTECTED]> writes: > And that is its plan (attached one is the same, but with costs): > >>-< > Merge Left Join >Merge Cond: ("outer".name = "inner".name) >-> Sort > Sort Key: log.name

Re: [SQL] Incomprehensible dogged sort in Merge Join

2007-08-31 Thread Tom Lane
Aleksandr Vinokurov <[EMAIL PROTECTED]> writes: > Trying to get an extra time savings in my query, I stopped at an unusual > doggedness of the planner. > Merge Left Join > Merge Cond: ("outer".name = "inner".name) > -> Sort > Sort Key: log.name > -> Seq Scan on log

[SQL] Incomprehensible dogged sort in Merge Join

2007-08-31 Thread Aleksandr Vinokurov
Hello all, Trying to get an extra time savings in my query, I stopped at an unusual doggedness of the planner. Here is the query: >-< select * from ( select * from "user_history" order by name ) as uh