| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Tim Perdue <tim(at)sourceforge(dot)net> |
| Cc: | pgsql-hackers(at)hub(dot)org |
| Subject: | Re: Interesting new bug? |
| Date: | 2000-08-23 03:35:50 |
| Message-ID: | 23904.967001750@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Tim Perdue <tim(at)sourceforge(dot)net> writes:
> I'm attempting to select out of a large table (10GB) with about 4
> million rows, and it winds up just sitting and doing "nothing" forever.
> db_geocrawler=# explain SELECT * FROM tbl_mail_archive WHERE
> fld_mail_list=0 ORDER BY fld_mailid ASC LIMIT 10 OFFSET 0;
> NOTICE: QUERY PLAN:
> Index Scan using tbl_mail_archive_pkey on tbl_mail_archive
> (cost=0.00..6402391.68 rows=19357 width=80)
Interesting. Since there's no explicit sort in the plan, I infer that
index tbl_mail_archive_pkey is on fld_mailid, meaning that the indexscan
yields data already sorted by fld_mailid --- otherwise a sort step would
be needed. Evidently the optimizer is guessing that "scan in fld_mailid
order until you have 10 rows where fld_mail_list=0" is faster than
"find all rows with fld_mail_list=0 and then sort by fld_mailid".
Since you're complaining, I guess that this is not so :-( ... but I'm
not sure how the optimizer might be taught to guess that. What exactly
are the indexes *on* here; how many rows are in the table; and how many
rows satisfy fld_mail_list=0?
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2000-08-23 04:16:15 | Re: Re: lost records --- problem identified! |
| Previous Message | Mitch Vincent | 2000-08-23 03:21:52 | Re: How Do You Pronounce "PostgreSQL"? |