the results from a query - question

From: "Johnson, Shaunn" <SJohnson6(at)bcbsm(dot)com>
To: "pgsql (E-mail)" <pgsql-general(at)postgresql(dot)org>
Subject: the results from a query - question
Date: 2003-04-02 14:00:33
Message-ID: 73309C2FDD95D11192E60008C7B1D5BB04C74899@snt452.corp.bcbsm.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Running PostgreSQL 7.2.1 on RedHat Linux 7.2.

Question - I'm looking at one of the users query

[snip query]
explain
select *
-- INTO dev_gm_er_prof01
FROM
db2_gm_reg_prof_01
WHERE
db2_gm_reg_prof_01.place_of_service = 2 and
db2_gm_reg_prof_01.diagnosis_cd not like '29%' and
db2_gm_reg_prof_01.diagnosis_cd not like '30%' and
db2_gm_reg_prof_01.diagnosis_cd not like '310%' and
db2_gm_reg_prof_01.diagnosis_cd not like '311%' and
db2_gm_reg_prof_01.diagnosis_cd not like '312%' and
db2_gm_reg_prof_01.diagnosis_cd not like '313%' and
db2_gm_reg_prof_01.diagnosis_cd not like '314%' and
db2_gm_reg_prof_01.diagnosis_cd not like '315%' and
db2_pos_reg_prof_01.diagnosis_cd not like '316%'
--ORDER BY
-- db2_gm_reg_prof_01.contract_num ASC;

[/snip query]

And doing an EXPLAIN, I come up with this -

[snip explain]

psql:./marsha_2apr.sql:19: NOTICE: Adding missing FROM-clause entry for
table "db2_pos_reg_prof_01"
psql:./marsha_2apr.sql:19: NOTICE: QUERY PLAN:

Nested Loop (cost=0.00..391628573.33 rows=4587594094 width=402)
-> Index Scan using db2_gm_prof_pos_01_i on db2_gm_reg_prof_01
(cost=0.00..8298.20 rows=2036 width=402)
-> Seq Scan on db2_pos_reg_prof_01 (cost=0.00..169793.33 rows=2252945
width=0)

[/snip explain]

Is this *really* supposed to bring back 4587594094 rows into this
table they are trying to create? I mean, I see obvious things (like the
file system growing like mad), but I just want to be sure before
I start making wild accusations.

Thanks!

-X

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Pedro Alves 2003-04-02 14:01:01 Forcing use of indexes
Previous Message rx 2003-04-02 13:44:20 help for postgreSQL in shell