Re: [PERFORM] poor execution plan because column dependence

2011-04-15 Thread Václav Ovsík
Dear Tom, On Thu, Apr 14, 2011 at 10:10:44AM -0400, Tom Lane wrote: > =?iso-8859-1?Q?V=E1clav_Ovs=EDk?= writes: > > I'm not certain about your sentence touching int4eq() and index. The > > execution plan as show in my previous mail contains information about > > using index tickets5: > > >

[PERFORM] Re: HashJoin order, hash the large or small table? Postgres likes to hash the big one, why?

2011-04-15 Thread pasman pasmański
hi. >I think you're missing the point, which is that all the hash work is >just pure overhead in such a case (and it is most definitely not >zero-cost overhead). You might as well just do a nestloop join. >Hashing is only beneficial to the extent that it allows a smaller subset >of the inner rela

[PERFORM] Bad Query Plan with Range Query

2011-04-15 Thread Mark Williams
We are experiencing a problem with our query plans when using a range query in Postgresql 8.3. The query we are executing attempts to select the minimum primary key id after a certain date. Our date columns are bigint's holding a unix epoch representation of the date. We have an index on the pr

Re: [PERFORM] Bad Query Plan with Range Query

2011-04-15 Thread Kenneth Marshall
On Fri, Apr 15, 2011 at 10:17:32AM -0700, Mark Williams wrote: > We are experiencing a problem with our query plans when using a range query > in Postgresql 8.3. The query we are executing attempts to select the > minimum primary key id after a certain date. Our date columns are bigint's > holdi

Re: [PERFORM] Bad Query Plan with Range Query

2011-04-15 Thread Kevin Grittner
Mark Williams wrote: > explain SELECT min(messageID) FROM Message > WHERE modificationDate >= 1302627793988; > For some reason it is deciding to scan the primary key column of > the table. This results in scanning the entire table No, it scans until it finds the first row where modificatio

Re: [PERFORM] Bad Query Plan with Range Query

2011-04-15 Thread Mark Williams
Thanks for the response guys. There is something else which confuses me. If I re-write the query like this: explain SELECT messageID FROM Message WHERE modificationDate >= 1302627793988 ORDER BY modificationDate LIMIT 1; QUERY PLAN ---

Re: [PERFORM] Bad Query Plan with Range Query

2011-04-15 Thread Kevin Grittner
Mark Williams wrote: > If I re-write the query like this: > > explain SELECT messageID FROM Message WHERE modificationDate >= > 1302627793988 ORDER BY modificationDate LIMIT 1; > I also get a better plan. Yeah, but it's not necessarily the same value. Do you want the minimum messageID whe

Re: [PERFORM] Bad Query Plan with Range Query

2011-04-15 Thread Mark Williams
Whoops, I meant this query (ordering my messageid): SELECT messageID FROM Message WHERE modificationDate>= 1302627793988 ORDER BY messageID LIMIT 1; Sometimes this gives the better plan. But not always. On 04/15/2011 11:13 AM, Kevin Grittner wrote: Mark Williams wrote: If I re-write th