Re: [PERFORM] Planner issue on sorting joining of two tables with limit

2010-05-16 Thread Robert Haas
On Fri, May 7, 2010 at 11:35 AM, Tom Lane wrote: > "Kevin Grittner" writes: >> Alexander Korotkov wrote: I just don't find why it is coincidence. I think that such plan will always produce result ordered by two columns, because such nested index scan always produce this result. >

Re: [PERFORM] Planner issue on sorting joining of two tables with limit

2010-05-07 Thread Tom Lane
"Kevin Grittner" writes: > Alexander Korotkov wrote: >>> I just don't find why it is coincidence. I think that such plan >>> will always produce result ordered by two columns, because such >>> nested index scan always produce this result. > Assuming a nested index scan, or any particular plan,

Re: [PERFORM] Planner issue on sorting joining of two tables with limit

2010-05-07 Thread Kevin Grittner
Alexander Korotkov wrote: > Alexander Korotkov wrote: >>> Well, no, because that plan wouldn't produce the specified >>> ordering; or at least it would be a lucky coincidence if it did. >>> It's only sorting on t1.value. >>> >> I just don't find why it is coincidence. I think that such plan >>

Re: [PERFORM] Planner issue on sorting joining of two tables with limit

2010-05-07 Thread Alexander Korotkov
I found my mistake. My supposition is working only if value column in t1 table is unique. But if I replace the index by unique one then plan is the same. On Mon, May 3, 2010 at 5:57 PM, Alexander Korotkov wrote: > Well, no, because that plan wouldn't produce the specified ordering; >> or at least

Re: [PERFORM] Planner issue on sorting joining of two tables with limit

2010-05-07 Thread Alexander Korotkov
> > Well, no, because that plan wouldn't produce the specified ordering; > or at least it would be a lucky coincidence if it did. It's only > sorting on t1.value. > I just don't find why it is coincidence. I think that such plan will always produce result ordered by two columns, because such neste

Re: [PERFORM] Planner issue on sorting joining of two tables with limit

2010-04-26 Thread Tom Lane
=?KOI8-R?B?68/Sz9TLz9cg4czFy9PBzsTS?= writes: > So PostgreSQL planner can produce the plan I need but it doesn't produce > this plan when I specify particular second ordering column. Well, no, because that plan wouldn't produce the specified ordering; or at least it would be a lucky coincidence i

[PERFORM] Planner issue on sorting joining of two tables with limit

2010-04-26 Thread Коротков Александр
Hello, everybody! I'm using PostgreSQL 8.4.3, compiled by Visual C++ build 1400, 32-bit on Windows XP SP3. I use following data model for issue reproducing. CREATE TABLE test1 ( id integer NOT NULL, "value" double precision, CONSTRAINT test1_pkey PRIMARY KEY (id) ); CREATE INDEX test1_valu

Re: [PERFORM] Planner issue

2005-03-22 Thread Ron Mayer
I'm guessing your data is actually more "clustered" than the "correlation" statistic thinks it is. Alex Turner wrote: > trendmls=# explain analyze select listnum from propmain where > listprice<=30 and listprice>=20; Is that a database of properties like land/houses?

Re: [PERFORM] Planner issue

2005-03-22 Thread Ron Mayer
I'm guessing your data is actually more "clustered" than the "correlation" stastic thinks it is. Alex Turner wrote: > trendmls=# explain analyze select listnum from propmain where > listprice<=30 and listprice>=20; Is that a database of properties like land/houses? If

Re: [PERFORM] Planner issue

2005-03-22 Thread Ragnar Hafstað
On Tue, 2005-03-22 at 14:36 -0500, Alex Turner wrote: > I will use an index 220-300, but not 200-300. > ... > Seq Scan on propmain (cost=0.00..15517.56 rows=6842 width=4) (actual > time=0.039..239.760 rows=6847 loops=1) > ... > Index Scan using propmain_listprice_i on propmain > (cost=0.00..22

Re: [PERFORM] Planner issue

2005-03-22 Thread Alex Turner
This helps a bit when I set it to 1000 - but it's still pretty bad: I will use an index 220-300, but not 200-300. Alex trendmls=# explain analyze select listnum from propmain where listprice<=30 and listprice>=20; QUERY PLAN

Re: [PERFORM] Planner issue

2005-03-22 Thread Joshua D. Drake
Alex Turner wrote: I get the following output from explain analyze on a certain subset of a large query I'm doing. Try increases the statistics on the listprice column with alter table and then re-run analyze. alter table foo alter column set statistics Sincerely, Joshua D. Drake From the look

[PERFORM] Planner issue

2005-03-22 Thread Alex Turner
I get the following output from explain analyze on a certain subset of a large query I'm doing. >From the looks of it, I need to increase how often postgres uses an index over a seq scan, but I'm not sure how to do that. I looked through the run-time configuration docs on the website, but didn't