[SQL] Sequence vs. Index Scan

2007-05-05 Thread Aaron Bono
I have two schemas, both with the exact same DDL. One performs great and the other has problems with a specific query: SELECT * FROM branch_active_vw WHERE branch_id = get_branch_for_zip ( '22151' ) ORDER BY branch_name ; I am not defining the view here because the explain plans show the rea

Re: [SQL] Sequence vs. Index Scan

2007-05-05 Thread Andrew Sullivan
On Sat, May 05, 2007 at 04:05:52PM -0500, Aaron Bono wrote: > I have two schemas, both with the exact same DDL. One performs great and Do they have the same data? > I have > checked and there IS an index, specifically a primary key index, on the > branch_id in both schemas so I cannot figure ou

Re: [SQL] Sequence vs. Index Scan

2007-05-05 Thread Aaron Bono
On 5/5/07, Andrew Sullivan <[EMAIL PROTECTED]> wrote: On Sat, May 05, 2007 at 04:05:52PM -0500, Aaron Bono wrote: > I have two schemas, both with the exact same DDL. One performs great and Do they have the same data? They have different data. The fast one has about 150 rows and the slow o

Re: [SQL] Sequence vs. Index Scan

2007-05-05 Thread Tom Lane
"Aaron Bono" <[EMAIL PROTECTED]> writes: > 9. -> Seq Scan on branch (cost=0.00..4.72 rows=1 > width=1281) (actual time=130129.988..157492.057 rows=1 loops=1) > 10.Filter: ((start_day <= now()) AND > ((end_day IS NULL) OR (end_day >= now())

Re: [SQL] Sequence vs. Index Scan

2007-05-05 Thread Andrew Sullivan
On Sat, May 05, 2007 at 05:00:53PM -0500, Aaron Bono wrote: > > They have different data. The fast one has about 150 rows and the slow one > has about 40 rows. The field in question here, the branch_id, is a > BIGSERIAL in both. I'd be astonished if a table of 40 rows ever got index scanned.

Re: [SQL] Sequence vs. Index Scan

2007-05-05 Thread Aaron Bono
On 5/5/07, Tom Lane <[EMAIL PROTECTED]> wrote: "Aaron Bono" <[EMAIL PROTECTED]> writes: > 9. -> Seq Scan on branch (cost=0.00..4.72rows=1 > width=1281) (actual time=130129.988..157492.057 rows=1 loops=1) > 10.Filter: ((start_day <= now(

Re: [SQL] Sequence vs. Index Scan

2007-05-05 Thread Aaron Bono
On 5/5/07, Andrew Sullivan <[EMAIL PROTECTED]> wrote: On Sat, May 05, 2007 at 05:00:53PM -0500, Aaron Bono wrote: > We don't allow deletes and updates are fairly infrequent. I also did a > vacuum analyze to no effect. How do you "not allow" deletes? Permissions are set on the tables to onl

Re: [SQL] Sequence vs. Index Scan

2007-05-05 Thread Aaron Bono
On 5/5/07, Tom Lane <[EMAIL PROTECTED]> wrote: "Aaron Bono" <[EMAIL PROTECTED]> writes: > 9. -> Seq Scan on branch (cost=0.00..4.72rows=1 > width=1281) (actual time=130129.988..157492.057 rows=1 loops=1) > 10.Filter: ((start_day <= now(

Re: [SQL] Sequence vs. Index Scan

2007-05-05 Thread Jaime Casanova
On 5/5/07, Aaron Bono <[EMAIL PROTECTED]> wrote: On 5/5/07, Tom Lane <[EMAIL PROTECTED]> wrote: > "Aaron Bono" <[EMAIL PROTECTED]> writes: > > 9. -> Seq Scan on branch (cost=0.00..4.72 rows=1 > > width=1281) (actual time= 130129.988..157492.057 rows=1 loops=1) > > 10.