Re: [PERFORM] Postgres 9.0 has a bias against indexes

2011-01-27 Thread Kevin Grittner
Mladen Gogala wrote: > Yes, Oracle can be forced into doing a sequential scan and it is > actually faster than an index scan: And PostgreSQL can be coerced to use an indexed scan. Its plans are cost-based, with user configurable cost factors; so if you tell it that seq_page_cost and random_

Re: [PERFORM] Postgres 9.0 has a bias against indexes

2011-01-27 Thread Mladen Gogala
On 1/27/2011 4:25 PM, Scott Marlowe wrote: On Oracle? Then how can it get the values it needs without having to hit the data store? It can't. It does hit the data store. -- Mladen Gogala Sr. Oracle DBA 1500 Broadway New York, NY 10036 (212) 329-5251 www.vmsinfo.com -- Sent via pgsql-perform

Re: [PERFORM] Postgres 9.0 has a bias against indexes

2011-01-27 Thread Scott Marlowe
On Thu, Jan 27, 2011 at 2:32 PM, Igor Neyman wrote: >> On Oracle?  Then how can it get the values it needs without >> having to hit the data store? > > It doesn't. > It does "INDEX UNIQUE SCAN" and then "TABLE ACCESS BY INDEX ROWID". Ahhh, ok. I thought Oracle used covering indexes by default.

Re: [PERFORM] Postgres 9.0 has a bias against indexes

2011-01-27 Thread Igor Neyman
To: Igor Neyman > >> Cc: Mladen Gogala; Tom Lane; David Wilson; Kenneth Marshall; > >> pgsql-performance@postgresql.org > >> Subject: Re: [PERFORM] Postgres 9.0 has a bias against indexes > >> > >> On Thu, Jan 27, 2011 at 2:12 PM, Igor Neyman >

Re: [PERFORM] Postgres 9.0 has a bias against indexes

2011-01-27 Thread Mladen Gogala
On 1/27/2011 4:20 PM, Kenneth Marshall wrote: Interesting. Can you force it to use a Seqential Scan and if so, how does that affect the timing? i.e. Is the index scan actually faster? Cheers, Ken Yes, Oracle can be forced into doing a sequential scan and it is actually faster than an index sca

Re: [PERFORM] Postgres 9.0 has a bias against indexes

2011-01-27 Thread Scott Marlowe
th Marshall; >> pgsql-performance@postgresql.org >> Subject: Re: [PERFORM] Postgres 9.0 has a bias against indexes >> >> On Thu, Jan 27, 2011 at 2:12 PM, Igor Neyman >> wrote: >> > >> > >> >> -Original Message- >> >> From: Scott

Re: [PERFORM] Postgres 9.0 has a bias against indexes

2011-01-27 Thread Kenneth Marshall
Wilson; Kenneth Marshall; > > pgsql-performance@postgresql.org > > Subject: Re: [PERFORM] Postgres 9.0 has a bias against indexes > > > > On Thu, Jan 27, 2011 at 1:44 PM, Mladen Gogala > > wrote: > > > On 1/27/2011 3:37 PM, Scott Marlowe wrote: &

Re: [PERFORM] Postgres 9.0 has a bias against indexes

2011-01-27 Thread Igor Neyman
t;> To: Mladen Gogala > >> Cc: Igor Neyman; Tom Lane; David Wilson; Kenneth Marshall; > >> pgsql-performance@postgresql.org > >> Subject: Re: [PERFORM] Postgres 9.0 has a bias against indexes > >> > >> On Thu, Jan 27, 2011 at 1:44 PM, Mladen Gogala &g

Re: [PERFORM] Postgres 9.0 has a bias against indexes

2011-01-27 Thread Scott Marlowe
nneth Marshall; >> pgsql-performance@postgresql.org >> Subject: Re: [PERFORM] Postgres 9.0 has a bias against indexes >> >> On Thu, Jan 27, 2011 at 1:44 PM, Mladen Gogala >> wrote: >> > On 1/27/2011 3:37 PM, Scott Marlowe wrote: >> >> >> >> On

Re: [PERFORM] Postgres 9.0 has a bias against indexes

2011-01-27 Thread Igor Neyman
> -Original Message- > From: Scott Marlowe [mailto:scott.marl...@gmail.com] > Sent: Thursday, January 27, 2011 3:59 PM > To: Mladen Gogala > Cc: Igor Neyman; Tom Lane; David Wilson; Kenneth Marshall; > pgsql-performance@postgresql.org > Subject: Re: [PERFORM] Po

Re: [PERFORM] Postgres 9.0 has a bias against indexes

2011-01-27 Thread Scott Marlowe
On Thu, Jan 27, 2011 at 1:44 PM, Mladen Gogala wrote: > On 1/27/2011 3:37 PM, Scott Marlowe wrote: >> >> On Thu, Jan 27, 2011 at 1:31 PM, Mladen Gogala >>  wrote: >>> >>> There is INDEX UNIQUE SCAN PK_EMP.  Oracle will use an index. >> >> That's because Oracle has covering indexes. >> > I am not

Re: [PERFORM] Postgres 9.0 has a bias against indexes

2011-01-27 Thread Mladen Gogala
On 1/27/2011 3:37 PM, Scott Marlowe wrote: On Thu, Jan 27, 2011 at 1:31 PM, Mladen Gogala wrote: There is INDEX UNIQUE SCAN PK_EMP. Oracle will use an index. That's because Oracle has covering indexes. I am not sure what you mean by "covering indexes" but I hope that for the larger table I

Re: [PERFORM] Postgres 9.0 has a bias against indexes

2011-01-27 Thread Scott Marlowe
On Thu, Jan 27, 2011 at 1:31 PM, Mladen Gogala wrote: > There is INDEX UNIQUE SCAN PK_EMP.  Oracle will use an index. That's because Oracle has covering indexes. -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgr

Re: [PERFORM] Postgres 9.0 has a bias against indexes

2011-01-27 Thread Mladen Gogala
On 1/27/2011 3:10 PM, Igor Neyman wrote: Mladen, I don't think, this is exclusive Postgres feature. I'm pretty sure, Oracle optimizer will do "TABLE ACCESS (FULL)" instead of using index on 14-row table either. Regards, Igor Neyman Well, lets' see: SQL> select * from v$version; BANNER

Re: [PERFORM] Postgres 9.0 has a bias against indexes

2011-01-27 Thread Igor Neyman
> -Original Message- > From: Mladen Gogala [mailto:mladen.gog...@vmsinfo.com] > Sent: Thursday, January 27, 2011 12:00 PM > To: Tom Lane > Cc: David Wilson; Kenneth Marshall; pgsql-performance@postgresql.org > Subject: Re: Postgres 9.0 has a bias against indexes > > On 1/27/2011 11:40

Re: [PERFORM] Postgres 9.0 has a bias against indexes

2011-01-27 Thread Mladen Gogala
On 1/27/2011 11:40 AM, Tom Lane wrote: It is worth noting that EXPLAIN results should not be extrapolated to situations other than the one you are actually testing; for example, results on a toy-sized table cannot be assumed to apply to large tables. Well, that's precisely what I t

Re: [PERFORM] Postgres 9.0 has a bias against indexes

2011-01-27 Thread Tom Lane
David Wilson writes: > You're still using a 14 row table, though. Exactly. Please note what it says in the fine manual: It is worth noting that EXPLAIN results should not be extrapolated to situations other than the one you are actually testing; for example, results on a toy-sized t

Re: [PERFORM] Postgres 9.0 has a bias against indexes

2011-01-27 Thread David Wilson
On Thu, Jan 27, 2011 at 10:56 AM, Mladen Gogala wrote: > I even tried with an almost equivalent outer join: > > explain analyze select e1.empno,e1.ename,e2.empno,e2.ename > from emp e1 left outer join emp e2 on (e1.mgr=e2.empno); > QUERY PLAN > > >

Re: [PERFORM] Postgres 9.0 has a bias against indexes

2011-01-27 Thread Mladen Gogala
On 1/27/2011 10:51 AM, J Sisson wrote: Also, if random_page_cost is set to default (4.0), the planner will tend towards sequential scans. scott=> show random_page_cost; random_page_cost -- 1 (1 row) scott=> show seq_page_cost; seq_page_cost --- 2 (1 row) -- Mla

Re: [PERFORM] Postgres 9.0 has a bias against indexes

2011-01-27 Thread Mladen Gogala
On 1/27/2011 10:45 AM, Kenneth Marshall wrote: PostgreSQL will only use an index if the planner thinks that it will be faster than the alternative, a sequential scan in this case. For 14 rows, a sequential scan is 1 read and should actually be faster than the index. Did you try the query using EX

Re: [PERFORM] Postgres 9.0 has a bias against indexes

2011-01-27 Thread J Sisson
Odds are that a table of 14 rows will more likely be cached in RAM than a table of 14 million rows. PostgreSQL would certainly be more "openminded" to using an index if chances are low that the table is cached. If the table *is* cached, though, what point would there be in reading an index? Also

Re: [PERFORM] Postgres 9.0 has a bias against indexes

2011-01-27 Thread Kevin Grittner
Mladen Gogala wrote: > The optimizer will not use index, not even when I turn off both > hash and merge joins. This is not particularly important for a > table with 14 rows, but for a larger table, this is a problem. If it still does that with a larger table. Do you have an example of that?

Re: [PERFORM] Postgres 9.0 has a bias against indexes

2011-01-27 Thread Kenneth Marshall
On Thu, Jan 27, 2011 at 10:41:08AM -0500, Mladen Gogala wrote: > I have a table EMP, with 14 rows and a description like this: > scott=> \d+ emp > Table "public.emp" > Column |Type | Modifiers | Storage | > Description > --+-